It seems that we loop all categories and item types to build the circ matrix: 169 <tbody> 170 [% SET row_count = 0 %] 171 [% FOREACH c IN categorycodes %] 172 [% SET c = '' UNLESS c.defined %] 173 [% FOREACH i IN itemtypes %] This means that when we have a large number of both, the page becomes increasingly slow: Try loading the page several times, notings the load time Then: perl -e 'use t::lib::TestBuilder; my $builder=t::lib::TestBuilder->new(); for( my $i=0;$i<50;$i++){ $builder->build({ source=>"Itemtype"}); }' Note load times, then: perl -e 'use t::lib::TestBuilder; my $builder=t::lib::TestBuilder->new(); for( my $i=0;$i<50;$i++){ $builder->build({ source=>"Category"}); }' Note load times, then run each again NOte load times, I saw around 15 seconds when I had ~100 of each
Created attachment 164065 [details] [review] Bug 36447: Circ rules slow to load when many itemtypes and categories It seems that we loop all categories and item types to build the circ matrix. We should only loop over values that have actually been used in circulation rules. Test Plan: 1) Create 1000 itemtypes and category codes. You can use the following script: use t::lib::TestBuilder; my $builder = t::lib::TestBuilder->new(); $builder->build( { source => 'Category' } ) for 0..1000; $builder->build( { source => 'Itemtype' } ) for 0..1000; 2) Note the lengthy load time for smart-rules.pl 3) Apply this patch 4) Restart all the things! 5) Reload the page 6) Note the much faster load time!
Created attachment 164083 [details] [review] Bug 36447: Circ rules slow to load when many itemtypes and categories It seems that we loop all categories and item types to build the circ matrix. We should only loop over values that have actually been used in circulation rules. Test Plan: 1) Create 1000 itemtypes and category codes. You can use the following script: use t::lib::TestBuilder; my $builder = t::lib::TestBuilder->new(); $builder->build( { source => 'Category' } ) for 0..1000; $builder->build( { source => 'Itemtype' } ) for 0..1000; 2) Note the lengthy load time for smart-rules.pl 3) Apply this patch 4) Restart all the things! 5) Reload the page 6) Note the much faster load time! Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Created attachment 164121 [details] [review] Bug 36447: Circ rules slow to load when many itemtypes and categories It seems that we loop all categories and item types to build the circ matrix. We should only loop over values that have actually been used in circulation rules. Test Plan: 1) Create 1000 itemtypes and category codes. You can use the following script: use t::lib::TestBuilder; my $builder = t::lib::TestBuilder->new(); $builder->build( { source => 'Category' } ) for 0..1000; $builder->build( { source => 'Itemtype' } ) for 0..1000; 2) Note the lengthy load time for smart-rules.pl 3) Apply this patch 4) Restart all the things! 5) Reload the page 6) Note the much faster load time! Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Pushed for 24.05! Well done everyone, thank you!
Would it be possible to backport this for 23.11?
Pushed to 23.11.x for 23.11.05
Missing 23.05.x dependencies, no backport.