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.
Created attachment 164023 [details] Before
Created attachment 164024 [details] After
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
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
Created attachment 164027 [details] [review] Bug 36441: Add comment explaining why replacing the DBIx call