Bug 36441 - Improve performance of Item::is_bundle
Summary: Improve performance of Item::is_bundle
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: David Gustafsson
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-27 18:12 UTC by David Gustafsson
Modified: 2024-03-27 18:36 UTC (History)
0 users

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Before (282.93 KB, image/png)
2024-03-27 18:19 UTC, David Gustafsson
Details
After (283.48 KB, image/png)
2024-03-27 18:19 UTC, David Gustafsson
Details
Bug 36441: Improve performance of Item::is_bundle (1.82 KB, patch)
2024-03-27 18:24 UTC, David Gustafsson
Details | Diff | Splinter Review
Bug 36441: Improve performance of Item::is_bundle (1.79 KB, patch)
2024-03-27 18:28 UTC, David Gustafsson
Details | Diff | Splinter Review
Bug 36441: Add comment explaining why replacing the DBIx call (863 bytes, patch)
2024-03-27 18:36 UTC, David Gustafsson
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Gustafsson 2024-03-27 18:12:11 UTC
For a biblio with a large number of holdings (which could be the case for serials for example) Item::is_bundle is one of the main culprits in terms of performance. I know it's usually frowned upon substituting DBIx queries with the DBI-equivalent, but think there are few other option in this case and should be very unlikely to cause any future regressions. Attached before and after flamegraphs to illustrate the difference in performance.
Comment 1 David Gustafsson 2024-03-27 18:19:29 UTC
Created attachment 164023 [details]
Before
Comment 2 David Gustafsson 2024-03-27 18:19:42 UTC
Created attachment 164024 [details]
After
Comment 3 David Gustafsson 2024-03-27 18:24:00 UTC
Created attachment 164025 [details] [review]
Bug 36441: Improve performance of Item::is_bundle

Perform count using DBI-query in Item::is_bundle to
significantly improve performance.

To test:
1) Go to the details page of a bibio with a large number
   of holdings holdings, preferably more than a hundred,
   and take note of page load time.
3) Apply patch
4) Reload the page and take note of page load time.
5) There should be an improvement of about 10-15%
6) Ensure tests in t/db_dependent/Koha/Item.t pass

Sponsored-by: Gothenburg University Library
Comment 4 David Gustafsson 2024-03-27 18:28:17 UTC
Created attachment 164026 [details] [review]
Bug 36441: Improve performance of Item::is_bundle

Perform count using DBI-query in Item::is_bundle to
significantly improve performance.

To test:
1) Go to the details page of a bibio with a large number
   of holdings holdings, preferably more than a hundred,
   and take note of page load time.
3) Apply patch
4) Reload the page and take note of page load time.
5) There should be an improvement of about 10-15%
6) Ensure tests in t/db_dependent/Koha/Item.t pass

Sponsored-by: Gothenburg University Library
Comment 5 David Gustafsson 2024-03-27 18:36:31 UTC
Created attachment 164027 [details] [review]
Bug 36441: Add comment explaining why replacing the DBIx call