Bug 37591

Summary: Moredetail.tt page is opening very slowly
Product: Koha Reporter: Johanna Räisä <johanna.raisa>
Component: CatalogingAssignee: Johanna Räisä <johanna.raisa>
Status: Pushed to oldstable --- QA Contact: Emily Lamancusa (emlam) <emily.lamancusa>
Severity: normal    
Priority: P5 - low CC: danielle.elder, david, emily.lamancusa, fridolin.somers, lucas, m.de.rooy, wainuiwitikapark
Version: Main   
Hardware: All   
OS: All   
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:
Bug Depends on: 35310    
Bug Blocks:    
Attachments: Bug 37591: fix moredetail.tt performance issue
A script to add checkouts and renewals
Bug 37591: fix moredetail.tt performance issue
Bug 37591: fix moredetail.tt performance issue

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