Bugzilla – Attachment 164026 Details for
Bug 36441
Improve performance of Item::is_bundle
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36441: Improve performance of Item::is_bundle
Bug-36441-Improve-performance-of-Itemisbundle.patch (text/plain), 1.79 KB, created by
David Gustafsson
on 2024-03-27 18:28:17 UTC
(
hide
)
Description:
Bug 36441: Improve performance of Item::is_bundle
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2024-03-27 18:28:17 UTC
Size:
1.79 KB
patch
obsolete
>From ab44ccd0203a4e359504353c76ba1994acbd4040 Mon Sep 17 00:00:00 2001 >From: Stefan Berndtsson <stefan.berndtsson@gmail.com> >Date: Fri, 4 Nov 2022 13:46:15 +0100 >Subject: [PATCH] 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 >--- > Koha/Item.pm | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 22eaceac948..7d3c9c22d5c 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -55,6 +55,7 @@ use Koha::StockRotationItem; > use Koha::StockRotationRotas; > use Koha::TrackedLinks; > use Koha::Policy::Holds; >+use Koha::Cache::Memory::Lite; > > use base qw(Koha::Object); > >@@ -1857,7 +1858,17 @@ Returns whether the item is a bundle or not > > sub is_bundle { > my ($self) = @_; >- return $self->bundle_items->count ? 1 : 0; >+ my $memory_cache = Koha::Cache::Memory::Lite->get_instance; >+ my $cache_key = 'Koha::Item:is_bundle_dbi_sth'; >+ my $sth = $memory_cache->get_from_cache($cache_key); >+ unless (defined $sth) { >+ my $query = "SELECT COUNT(*) FROM items i LEFT JOIN item_bundles ib ON i.itemnumber = ib.item WHERE ib.host = ?"; >+ my $dbh = C4::Context->dbh; >+ $sth = $dbh->prepare($query); >+ $memory_cache->set_in_cache($cache_key, $sth); >+ } >+ $sth->execute($self->itemnumber); >+ return $sth->fetchrow_arrayref()->[0] ? 1 : 0; > } > > =head3 bundle_host >-- >2.43.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36441
:
164023
|
164024
|
164025
| 164026 |
164027