Bugzilla – Attachment 36873 Details for
Bug 13740
Timeout on deleting patrons if too many patrons
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 13740: Remove the NOT NULL clause in GetBorrowersToExpunge
PASSED-QA-Bug-13740-Remove-the-NOT-NULL-clause-in-.patch (text/plain), 2.23 KB, created by
Kyle M Hall (khall)
on 2015-03-13 18:07:22 UTC
(
hide
)
Description:
[PASSED QA] Bug 13740: Remove the NOT NULL clause in GetBorrowersToExpunge
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-03-13 18:07:22 UTC
Size:
2.23 KB
patch
obsolete
>From 7af98fc0646f2cc3d7a08878481a74978ca46b42 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Fri, 20 Feb 2015 16:23:50 +0100 >Subject: [PATCH] [PASSED QA] Bug 13740: Remove the NOT NULL clause in GetBorrowersToExpunge > >C4::Borrowers::GetBorrowersToExpunge should not use a "NOT IN", it is >not efficient at all. > >With only 1 guarantor and more than 136k patrons, the not in clause in >this subroutine takes ages: >mysql> select count(*) FROM borrowers where borrowernumber NOT IN >(SELECT guarantorid FROM borrowers WHERE guarantorid IS NOT NULL AND >guarantorid <> 0) ; >[...] > >not ended after 5min > >With the query modified by this patch, the results come after 1 sec :) > >Test plan: >Verify the delete_patrons.pl cronjob or the cleanborrowers tools work as >before. >Especially with guarantors. > >Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com> > >Signed-off-by: Koha Team AMU <koha.aixmarseille@gmail.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/Members.pm | 13 ++++++++++--- > 1 files changed, 10 insertions(+), 3 deletions(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index 4fb845d..c1b4b1e 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -2111,17 +2111,24 @@ sub GetBorrowersToExpunge { > : ""); > > my $dbh = C4::Context->dbh; >- my $query = " >+ my $query = q| > SELECT borrowers.borrowernumber, > MAX(old_issues.timestamp) AS latestissue, > MAX(issues.timestamp) AS currentissue > FROM borrowers > JOIN categories USING (categorycode) >+ LEFT JOIN ( >+ SELECT guarantorid >+ FROM borrowers >+ WHERE guarantorid IS NOT NULL >+ AND guarantorid <> 0 >+ ) as tmp ON borrowers.borrowernumber=tmp.guarantorid > LEFT JOIN old_issues USING (borrowernumber) > LEFT JOIN issues USING (borrowernumber) > WHERE category_type <> 'S' >- AND borrowernumber NOT IN (SELECT guarantorid FROM borrowers WHERE guarantorid IS NOT NULL AND guarantorid <> 0) >- "; >+ AND tmp.guarantorid IS NOT NULL >+ |; >+ > my @query_params; > if ( $filterbranch && $filterbranch ne "" ) { > $query.= " AND borrowers.branchcode = ? "; >-- >1.7.2.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 13740
:
36096
|
36150
|
36157
|
36410
|
36411
| 36873 |
36874