Bug 35921: Improve perfs of acqui-home.pl when there are many budgets
authorJulian Maurice <julian.maurice@biblibre.com>
Thu, 25 Jan 2024 15:49:32 +0000 (16:49 +0100)
committerLucas Gass <lucas@bywatersolutions.com>
Mon, 13 May 2024 14:32:50 +0000 (14:32 +0000)
commitf017560b9df7a6613b13de797be8efc3a5446cc9
tree002bb2595d44051ac86045e274a401e378449f3f
parent32a226ad7fabb16059c1c9cea0887a415aa27a69
Bug 35921: Improve perfs of acqui-home.pl when there are many budgets

When there are a lot of budgets with the same owner, most of the time of
acqui-home.pl is spent loading the same patron over and over.

This patch makes sure each borrower is loaded only once.

Test plan:
0. Do not apply the patch yet
1. Create a thousand budgets with the following command (make sure the
   budget_owner_id is an existing borrowernumber):
       perl -MKoha::Database -e '
           my $schema = Koha::Database->schema;
           my $period = $schema->resultset("Aqbudgetperiod")->create({
               budget_period_startdate => "2000-01-01",
               budget_period_enddate => "2999-12-31"
           });
           $schema->resultset("Aqbudget")->create({
               budget_owner_id => 1,
               budget_period_id => $period->id
           }) for (1..1000)
       '
2. Measure the time it takes to load acqui/acqui-home.pl (do it several
   times and keep the average time)
3. Apply the patch
4. Repeat step 2

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 24b33936a526187e17719294e236f186aec46d50)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit b37e510eb8c2b280a69dfb60c427c60d1d53b041)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
acqui/acqui-home.pl