Bugzilla – Attachment 164025 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.82 KB, created by
David Gustafsson
on 2024-03-27 18:24:00 UTC
(
hide
)
Description:
Bug 36441: Improve performance of Item::is_bundle
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2024-03-27 18:24:00 UTC
Size:
1.82 KB
patch
obsolete
>From 222b36f284cdabbdcbb67f0371a00b795cc3e30e 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 | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 22eaceac948..858ff545343 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,20 @@ Returns whether the item is a bundle or not > > sub is_bundle { > my ($self) = @_; >- return $self->bundle_items->count ? 1 : 0; >+ my $dbi_cache = Koha::Cache::Memory::Lite->get_instance; >+ my $cache_key = "DBI->count:is_bundle_count"; >+ my $sth = $dbi_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); >+ $dbi_cache->set_in_cache( $cache_key, $sth ); >+ } >+ >+ $sth->execute($self->itemnumber); >+ my $count = $sth->fetchrow_arrayref()->[0]; >+ >+ return $count ? 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