Bugzilla – Attachment 186192 Details for
Bug 28702
Improve performance of C4/XSLT/buildKohaItemsNamespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28702: Reduce DB lookups in buildKohaItemsNamespace
Bug-28702-Reduce-DB-lookups-in-buildKohaItemsNames.patch (text/plain), 2.42 KB, created by
Nick Clemens (kidclamp)
on 2025-09-05 10:43:40 UTC
(
hide
)
Description:
Bug 28702: Reduce DB lookups in buildKohaItemsNamespace
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2025-09-05 10:43:40 UTC
Size:
2.42 KB
patch
obsolete
>From f458e3f93b055524ee1f02b5935d8dc3f59263d4 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 3 Sep 2025 13:24:30 +0000 >Subject: [PATCH] Bug 28702: Reduce DB lookups in buildKohaItemsNamespace > >This patch moves the prefetch to current_branchtransfers and uses the prefetched reserves >and transfers to reduce the number of lookups from the DB > >We also don't fetch the specific current transfer, knowing we have current transfers is enough > >To test: >1 - Perform a search on the OPAC >2 - Add the results to a list >3 - Load the list several times and use developer tools (F12) to view the time to load in the network tab >4 - Repeat a search several times and use developer tools (F12) to view the time to load in the network tab >5 - Record the times noted above >6 - Find or create a record with many items, biblionumber 3 in my example >7 - on the command line: > export DBIC_TRACE=1 > perl -e 'use C4::XSLT; my $i = C4::XSLT::buildKohaItemsNamespace( 3 );' > note the lookups in reserves and transfers >8 - Apply patch >9 - Repeat 7 and note less lookups >10 - Repeat the search and list view and compare times to before the patch >11 - prove -v t/db_dependent/XSLT.t >--- > C4/XSLT.pm | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index 422a02b1ea7..88443ab27af 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -292,7 +292,8 @@ sub buildKohaItemsNamespace { > $items_rs = Koha::Items->new; > } > >- my $items = $items_rs->search( $query, { prefetch => [ 'branchtransfers', 'reserves' ] } ); >+ my $items = >+ $items_rs->search( $query, { prefetch => [ 'current_branchtransfers', 'reserves', 'tmp_holdsqueue' ] } ); > > my $shelflocations = { > map { $_->{authorised_value} => $_->{opac_description} } >@@ -333,10 +334,10 @@ sub buildKohaItemsNamespace { > } elsif ( $item->has_pending_hold ) { > $status = 'other'; > $substatus = 'Pending hold'; >- } elsif ( $item->holds->waiting->count ) { >+ } elsif ( $item->holds->count && $item->holds->waiting->count ) { > $status = 'other'; > $substatus = 'Hold waiting'; >- } elsif ( $item->get_transfer ) { >+ } elsif ( $item->_result->current_branchtransfers->count ) { > $status = 'other'; > $substatus = 'In transit'; > } elsif ( $item->damaged && !C4::Context->preference('AllowHoldsOnDamagedItems') ) { >-- >2.39.5
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 28702
:
122785
|
122786
|
137939
|
137940
|
138459
|
138468
|
186070
|
186071
|
186192
|
186193