[Bug 30359] New: GetBudgetHierarchy is slow on order receive page
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 Bug ID: 30359 Summary: GetBudgetHierarchy is slow on order receive page Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Acquisitions Assignee: koha-bugs@lists.koha-community.org Reporter: johanna.raisa@koha-suomi.fi QA Contact: testopia@bugs.koha-community.org GetBudgetHierarchy is called when opening orderreceive.pl and if there are lot of budgets the page takes lot of time to open. On our biggest groups it takes almost 2 minute, which is a lifetime on internet. Seems that the problem is calculating the totals, which are done with separate queries to the database. On the order receive page it is not needed since it is using only the budget_id, budget_amount and budget_name parameters. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 Johanna Räisä <johanna.raisa@koha-suomi.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Assignee|koha-bugs@lists.koha-commun |johanna.raisa@koha-suomi.fi |ity.org | --- Comment #1 from Johanna Räisä <johanna.raisa@koha-suomi.fi> --- Created attachment 132283 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=132283&action=edit Bug 30359: GetBudgetHierarchy is slow on order receive page This patch adds skiptotals parameter to GetBudgetHierarchy so calculating totals can be skipped from some pages. Test plan: 1) Open browser's Inspect -> Network 2) Go to receive orders 3) Check the timings for page load 4) Apply the patch 5) Refresh the page 6) Check the timings again 7) prove t/db_dependent/Budgets.t Sponsored-by: Koha-Suomi Oy -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 --- Comment #2 from Nick Clemens <nick@bywatersolutions.com> --- One this page we are calling GetBudgetHierarchy in a loop on al the budget periods - this seems to be extra work. Compare this to the way things are handled in neworderempty.pl: 333 my $budget = GetBudget($budget_id); 334 # build budget list 335 my $budget_loop = []; 336 my $budgets = GetBudgetHierarchy; 337 foreach my $r (@{$budgets}) { 338 next unless (CanUserUseBudget($patron, $r, $userflags)); 339 push @{$budget_loop}, { 340 b_id => $r->{budget_id}, 341 b_txt => $r->{budget_name}, 342 b_sort1_authcat => $r->{'sort1_authcat'}, 343 b_sort2_authcat => $r->{'sort2_authcat'}, 344 b_active => $r->{budget_period_active}, 345 b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0, 346 b_level => $r->{budget_level}, 347 }; 348 } I think we have other occurrences as well - we should consolidate this code and make the dropdowns work the same I am not against removing the totals, but I think the loop in the script is the bigger culprit here -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 --- Comment #3 from Johanna Räisä <johanna.raisa@koha-suomi.fi> --- (In reply to Nick Clemens from comment #2)
One this page we are calling GetBudgetHierarchy in a loop on al the budget periods - this seems to be extra work.
Compare this to the way things are handled in neworderempty.pl: 333 my $budget = GetBudget($budget_id); 334 # build budget list 335 my $budget_loop = []; 336 my $budgets = GetBudgetHierarchy; 337 foreach my $r (@{$budgets}) { 338 next unless (CanUserUseBudget($patron, $r, $userflags)); 339 push @{$budget_loop}, { 340 b_id => $r->{budget_id}, 341 b_txt => $r->{budget_name}, 342 b_sort1_authcat => $r->{'sort1_authcat'}, 343 b_sort2_authcat => $r->{'sort2_authcat'}, 344 b_active => $r->{budget_period_active}, 345 b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0, 346 b_level => $r->{budget_level}, 347 }; 348 }
I think we have other occurrences as well - we should consolidate this code and make the dropdowns work the same
I am not against removing the totals, but I think the loop in the script is the bigger culprit here
Yes, there might be other occurrences which need optimization too. When I investigated the culprit the loop didn't stand out. The real affect came from skipping the calculations. The improvement was huge, the waiting time was first 1.89 minutes and after this patch it went to 460ms. If some places we are using only part of what GetBudgetHierarchy offers, would it be a good idea make separate functions? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Trivial patch Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #132283|0 |1 is obsolete| | --- Comment #4 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 139765 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=139765&action=edit Bug 30359: GetBudgetHierarchy is slow on order receive page This patch adds skiptotals parameter to GetBudgetHierarchy so calculating totals can be skipped from some pages. Test plan: 1) Open browser's Inspect -> Network 2) Go to receive orders 3) Check the timings for page load 4) Apply the patch 5) Refresh the page 6) Check the timings again 7) prove t/db_dependent/Budgets.t Sponsored-by: Koha-Suomi Oy Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 --- Comment #5 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 139766 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=139766&action=edit Bug 30359: Unit tests Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |31459 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31459 [Bug 31459] Order receive page is slow on systems with many budgets -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|enhancement |normal -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 Joonas Kylmälä <joonas.kylmala@iki.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |joonas.kylmala@iki.fi |y.org | CC| |joonas.kylmala@iki.fi -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 Joonas Kylmälä <joonas.kylmala@iki.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #139765|0 |1 is obsolete| | Attachment #139766|0 |1 is obsolete| | --- Comment #6 from Joonas Kylmälä <joonas.kylmala@iki.fi> --- Created attachment 140017 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=140017&action=edit Bug 30359: GetBudgetHierarchy is slow on order receive page This patch adds skiptotals parameter to GetBudgetHierarchy so calculating totals can be skipped from some pages. Test plan: 1) Open browser's Inspect -> Network 2) Go to receive orders 3) Check the timings for page load 4) Apply the patch 5) Refresh the page 6) Check the timings again 7) prove t/db_dependent/Budgets.t Sponsored-by: Koha-Suomi Oy Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 --- Comment #7 from Joonas Kylmälä <joonas.kylmala@iki.fi> --- Created attachment 140018 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=140018&action=edit Bug 30359: Unit tests Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 Joonas Kylmälä <joonas.kylmala@iki.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to master Version(s)| |22.11.00 released in| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 --- Comment #8 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Pushed to master for 22.11. Nice work everyone, thanks! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 Lucas Gass <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lucas@bywatersolutions.com Version(s)|22.11.00 |22.11.00, 22.05.07 released in| | Status|Pushed to master |Pushed to stable --- Comment #9 from Lucas Gass <lucas@bywatersolutions.com> --- Backported to 22.05.x for upcoming 22.05.07 release -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 Arthur Suzuki <arthur.suzuki@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |arthur.suzuki@biblibre.com Version(s)|22.11.00, 22.05.07 |22.11.00, 22.05.07, released in| |21.11.14 Status|Pushed to stable |Pushed to oldstable --- Comment #10 from Arthur Suzuki <arthur.suzuki@biblibre.com> --- applied to 21.11 for 21.11.14 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to oldstable |RESOLVED CC| |victor@tuxayo.net Resolution|--- |FIXED --- Comment #11 from Victor Grousset/tuxayo <victor@tuxayo.net> --- Not backported to oldoldstable (21.05.x). Feel free to ask if it's needed. Nothing to document it seems, marking resolved. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 Emmi Takkinen <emmi.takkinen@koha-suomi.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |emmi.takkinen@koha-suomi.fi See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=32377 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30359 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org