Bugzilla – Attachment 126200 Details for
Bug 28833
Speed up holds queue builder via parallel processing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28833: Balance the number of holds each chunk contains
Bug-28833-Balance-the-number-of-holds-each-chunk-c.patch (text/plain), 2.32 KB, created by
Kyle M Hall (khall)
on 2021-10-13 13:46:17 UTC
(
hide
)
Description:
Bug 28833: Balance the number of holds each chunk contains
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-10-13 13:46:17 UTC
Size:
2.32 KB
patch
obsolete
>From 3c7bd0d3ea77567549364631f6bc37e84b4b8c9d Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 13 Oct 2021 09:45:56 -0400 >Subject: [PATCH] Bug 28833: Balance the number of holds each chunk contains > >--- > C4/HoldsQueue.pm | 28 ++++++++++++++++------------ > 1 file changed, 16 insertions(+), 12 deletions(-) > >diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm >index edf5eaf10e..2a6a1296f4 100644 >--- a/C4/HoldsQueue.pm >+++ b/C4/HoldsQueue.pm >@@ -258,14 +258,15 @@ sub CreateQueue { > > my $bibs_with_pending_requests = GetBibsWithPendingHoldRequests(); > >- # Split the list of bibs into groups to run in parallel >+ # Split the list of bibs into chunks to run in parallel > if ( $loops > 1 ) { >- my $bibs_per_chunk = ceil( scalar @$bibs_with_pending_requests / $loops ); >- $bibs_per_chunk = @$bibs_with_pending_requests if @$bibs_with_pending_requests <= $bibs_per_chunk; >- my @chunks; >+ my $i = 0; >+ while (@$bibs_with_pending_requests) { >+ push( @{ $chunks[$i] }, pop(@$bibs_with_pending_requests) ); > >- push( @chunks, [ splice @$bibs_with_pending_requests, 0, $bibs_per_chunk ] ) while @$bibs_with_pending_requests; >- push( @{$chunks[0]}, @$bibs_with_pending_requests ); # Add any remainders to the first parallel process >+ $i++; >+ $i = 0 if $i >= $loops; >+ } > > my $pm = Parallel::ForkManager->new($loops); > >@@ -335,12 +336,15 @@ that have one or more unfilled hold requests. > sub GetBibsWithPendingHoldRequests { > my $dbh = C4::Context->dbh; > >- my $bib_query = "SELECT DISTINCT biblionumber >- FROM reserves >- WHERE found IS NULL >- AND priority > 0 >- AND reservedate <= CURRENT_DATE() >- AND suspend = 0 >+ my $bib_query = "SELECT biblionumber, >+ COUNT(biblionumber) AS holds_count >+ FROM reserves >+ WHERE found IS NULL >+ AND priority > 0 >+ AND reservedate <= CURRENT_DATE() >+ AND suspend = 0 >+ GROUP BY biblionumber >+ ORDER BY biblionumber DESC > "; > my $sth = $dbh->prepare($bib_query); > >-- >2.30.1 (Apple Git-130)
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 28833
:
123656
|
123657
|
123659
|
123671
|
123679
|
123688
|
123689
|
123783
|
123784
|
123785
|
123786
|
123996
|
126200
|
126202
|
126216
|
167349
|
173045
|
173046
|
173262