Bugzilla – Attachment 93155 Details for
Bug 23624
Count rows in report without (potentially) consuming all memory
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23624: (QA follow-up) Optimize even more
Bug-23624-QA-follow-up-Optimize-even-more.patch (text/plain), 1.68 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-09-25 13:45:09 UTC
(
hide
)
Description:
Bug 23624: (QA follow-up) Optimize even more
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-09-25 13:45:09 UTC
Size:
1.68 KB
patch
obsolete
>From 391cce587016fdc5bce0803c3f66c997323c0a0d Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 19 Sep 2019 11:13:28 -0300 >Subject: [PATCH] Bug 23624: (QA follow-up) Optimize even more > >This patch makes counting the results have no memory footprint by >leveraging on the DB to count the rows. > >To test: >- Without this path, run: > $ kshell > k$ prove t/db_dependent/Reports/Guided.t >=> SUCCESS: Tests pass >- Apply this patch >- Run: > k$ prove t/db_dependent/Reports/Guided.t >=> SUCCESS: Tests still pass! > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Liz Rea <wizzyrea@gmail.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > C4/Reports/Guided.pm | 19 ++++++++++++------- > 1 file changed, 12 insertions(+), 7 deletions(-) > >diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm >index aae069195f..58d78002e0 100644 >--- a/C4/Reports/Guided.pm >+++ b/C4/Reports/Guided.pm >@@ -418,14 +418,19 @@ sub get_criteria { > > sub nb_rows { > my $sql = shift or return; >- my $sth = C4::Context->dbh->prepare($sql); >- $sth->execute(); >- my $n = 0; >- # Loop through the complete results, fetching 1,000 rows at a time. This >- # lowers memory requirements but increases execution time. >- while (my $rows = $sth->fetchall_arrayref(undef, 1000)) { >- $n += @$rows; >+ >+ my $derived_name = 'xxx'; >+ # make sure the derived table name is not already used >+ while ( $sql =~ m/$derived_name/ ) { >+ $derived_name .= 'x'; > } >+ my $sth = C4::Context->dbh->prepare(qq{ >+ SELECT COUNT(*) FROM >+ ( $sql ) $derived_name >+ }); >+ $sth->execute(); >+ my $n = $sth->fetch->[0]; >+ > return $n; > } > >-- >2.23.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 23624
:
92841
|
92903
|
92968
|
92969
|
92970
|
92974
|
92975
|
92976
|
92995
|
93037
|
93153
|
93154
| 93155 |
93156
|
93157