Bug 37591 - Moredetail.tt page is opening very slowly
Summary: Moredetail.tt page is opening very slowly
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Johanna Räisä
QA Contact: Emily Lamancusa (emlam)
URL:
Keywords:
Depends on: 35310
Blocks:
  Show dependency treegraph
 
Reported: 2024-08-07 11:57 UTC by Johanna Räisä
Modified: 2024-11-03 23:57 UTC (History)
7 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This improves the loading time of a record's items page in the staff item when there are many items and check-outs.
Version(s) released in:
24.11.00,24.05.04,23.11.10
Circulation function:


Attachments
Bug 37591: fix moredetail.tt performance issue (2.44 KB, patch)
2024-08-09 07:10 UTC, Johanna Räisä
Details | Diff | Splinter Review
A script to add checkouts and renewals (3.65 KB, application/x-perl)
2024-08-09 07:16 UTC, Johanna Räisä
Details
Bug 37591: fix moredetail.tt performance issue (2.50 KB, patch)
2024-08-12 20:43 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 37591: fix moredetail.tt performance issue (2.57 KB, patch)
2024-08-13 20:06 UTC, Emily Lamancusa (emlam)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Johanna Räisä 2024-08-07 11:57:59 UTC
Sometimes opening the moredetails.pl takes lot of time. This problem occurred when updated from 23.11 to 24.05.

I think it has to do something with how many items and checkouts you have on a record, for example having 99 items and most of them are checked out.
Comment 1 Johanna Räisä 2024-08-08 11:45:20 UTC
I figured out where the problem is. It is actually in the moredetail.tt and appeared after this Bug 35310. The view starts fetching renewals for checkouts and if there are lot of renewals for each of the item the page load takes lot of time. The count should probably made in the background, using objects on the views is causing performance issues.
Comment 2 Johanna Räisä 2024-08-09 07:10:59 UTC
Created attachment 170168 [details] [review]
Bug 37591: fix moredetail.tt performance issue

This patch fixes the performance issue in moredetail.tt by removing the
unnecessary call of checkout_renewals table.

To test:
1. Create lot of checkouts and renewals for a record.
2. Open the moredetail page for the record.
3. Check the timing of the page load.
4. Apply the patch and check the timing of the page load again.
5. The page load should be faster after applying the patch.

Sponsored-by: Koha-Suomi Oy
Comment 3 Johanna Räisä 2024-08-09 07:16:33 UTC
Created attachment 170169 [details]
A script to add checkouts and renewals

This bug is a bit hard to test. You will need lot of checkouts and data in the checkout_renewals table. In our case we have over 3 million rows in the checkout_renewals table and page load was over 2 minutes and it got reduced to 5 seconds after this patch.

I made a script which you can use for testing.
Comment 4 Lucas Gass (lukeg) 2024-08-12 20:43:52 UTC
Created attachment 170240 [details] [review]
Bug 37591: fix moredetail.tt performance issue

This patch fixes the performance issue in moredetail.tt by removing the
unnecessary call of checkout_renewals table.

To test:
1. Create lot of checkouts and renewals for a record.
2. Open the moredetail page for the record.
3. Check the timing of the page load.
4. Apply the patch and check the timing of the page load again.
5. The page load should be faster after applying the patch.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 5 Emily Lamancusa (emlam) 2024-08-13 20:06:21 UTC
Created attachment 170294 [details] [review]
Bug 37591: fix moredetail.tt performance issue

This patch fixes the performance issue in moredetail.tt by removing the
unnecessary call of checkout_renewals table.

To test:
1. Create lot of checkouts and renewals for a record.
2. Open the moredetail page for the record.
3. Check the timing of the page load.
4. Apply the patch and check the timing of the page load again.
5. The page load should be faster after applying the patch.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Comment 6 Emily Lamancusa (emlam) 2024-08-13 20:07:45 UTC
Thanks for the test script, Johanna! Starting from default KTD data and creating a bib with 2,000 items x 4 renewals each, I can confirm an improvement from 22.58s without the patch to 13.45s with the patch. The code and QA tool also look good - passing QA.
Comment 7 Katrin Fischer 2024-08-16 15:37:39 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 8 Lucas Gass (lukeg) 2024-09-11 16:53:11 UTC
Backported to 24.05.x for upcoming 24.05.04
Comment 9 Fridolin Somers 2024-10-21 12:20:03 UTC
Pushed to 23.11.x for 23.11.10
Comment 10 Wainui Witika-Park 2024-11-03 23:57:38 UTC
Not backporting to 23.05.x unless requested