Ajax script svc/checkouts display checkouts of a patron. For each item, it fetches a Koha::ItemType object and a Koha::AuthorisedValues object for location,ccode,lost and damaged. For performance on huge number of checkouts : Item types should be fetch once before the loop. authorised values should call Koha::AuthorisedValues->get_description_by_koha_field because it uses a cache.
Created attachment 109850 [details] [review] Bug 26424: Better performance of svc/checkouts Ajax script svc/checkouts display checkouts of a patron. For each item, it fetches a Koha::ItemType object and a Koha::AuthorisedValues object for location,ccode,lost and damaged. For performance on huge number of checkouts : Item types should be fetch once before the loop. authorised values should call Koha::AuthorisedValues->get_description_by_koha_field because it uses a cache. Test plan : 1) Dont apply patch 2) Use sql to define some items lost and damaged 3) Look at checkouts table on a patron with a lot of checkouts 4) Apply patch 5) Look at checkouts table again and check info are the same : record level item type, item type, location, collection, lost, damaged
Created attachment 109851 [details] [review] Bug 26424: Better performance of svc/checkouts Ajax script svc/checkouts display checkouts of a patron. For each item, it fetches a Koha::ItemType object and a Koha::AuthorisedValues object for location,ccode,lost and damaged. For performance on huge number of checkouts : Item types should be fetch once before the loop. authorised values should call Koha::AuthorisedValues->get_description_by_koha_field because it uses a cache. I've tested with Plack : Without patch : 100 checkouts = 6 seconds 1000 checkouts = 60 seconds With patch : 100 checkouts = 5 seconds 1000 checkouts = 44 seconds Test plan : 1) Dont apply patch 2) Use sql to define some items lost and damaged 3) Look at checkouts table on a patron with a lot of checkouts 4) Apply patch 5) Look at checkouts table again 6) Check infos are the same : record level item type, item type, location, collection, lost, damaged 7) Check infos are the same in "Number of checkouts by item type"
It's ok, but we should use the REST API sooner than later. We can embed things, etc.
(In reply to Tomás Cohen Arazi from comment #3) > It's ok, but we should use the REST API sooner than later. We can embed > things, etc. Yep indeed, but that will be a lot of work, this table is really complex.
Ah patch also changes the fact that authorised value categories are no longer hardcoded LOC,CCODE,LOST and DAMAGED, they depend on default framework. Like is doing Bug 26323
Created attachment 109883 [details] [review] Bug 26424: Better performance of svc/checkouts Ajax script svc/checkouts display checkouts of a patron. For each item, it fetches a Koha::ItemType object and a Koha::AuthorisedValues object for location,ccode,lost and damaged. For performance on huge number of checkouts : Item types should be fetch once before the loop. authorised values should call Koha::AuthorisedValues->get_description_by_koha_field because it uses a cache. I've tested with Plack : Without patch : 100 checkouts = 6 seconds 1000 checkouts = 60 seconds With patch : 100 checkouts = 5 seconds 1000 checkouts = 44 seconds Patch also changes the fact that authorised value categories are no longer hardcoded LOC,CCODE,LOST and DAMAGED, they depend on default framework. Like is doing Bug 26323. Test plan : 1) Dont apply patch 2) Use sql to define some items lost and damaged 3) Look at checkouts table on a patron with a lot of checkouts 4) Apply patch 5) Look at checkouts table again 6) Check infos are the same : record level item type, item type, location, collection, lost, damaged 7) Check infos are the same in "Number of checkouts by item type"
Created attachment 110209 [details] [review] Bug 26424: Better performance of svc/checkouts Ajax script svc/checkouts display checkouts of a patron. For each item, it fetches a Koha::ItemType object and a Koha::AuthorisedValues object for location,ccode,lost and damaged. For performance on huge number of checkouts : Item types should be fetch once before the loop. authorised values should call Koha::AuthorisedValues->get_description_by_koha_field because it uses a cache. I've tested with Plack : Without patch : 100 checkouts = 6 seconds 1000 checkouts = 60 seconds With patch : 100 checkouts = 5 seconds 1000 checkouts = 44 seconds Patch also changes the fact that authorised value categories are no longer hardcoded LOC,CCODE,LOST and DAMAGED, they depend on default framework. Like is doing Bug 26323. Test plan : 1) Dont apply patch 2) Use sql to define some items lost and damaged 3) Look at checkouts table on a patron with a lot of checkouts 4) Apply patch 5) Look at checkouts table again 6) Check infos are the same : record level item type, item type, location, collection, lost, damaged 7) Check infos are the same in "Number of checkouts by item type" Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Clear and sensible improvement works as expected. Signing off
Please check the fail from the QA script: FAIL svc/checkouts FAIL critic # Variables::ProhibitConditionalDeclarations: Got 2 violation(s).
Created attachment 110378 [details] [review] Bug 26424: Better performance of svc/checkouts Ajax script svc/checkouts display checkouts of a patron. For each item, it fetches a Koha::ItemType object and a Koha::AuthorisedValues object for location,ccode,lost and damaged. For performance on huge number of checkouts : Item types should be fetch once before the loop. authorised values should call Koha::AuthorisedValues->get_description_by_koha_field because it uses a cache. I've tested with Plack : Without patch : 100 checkouts = 6 seconds 1000 checkouts = 60 seconds With patch : 100 checkouts = 5 seconds 1000 checkouts = 44 seconds Patch also changes the fact that authorised value categories are no longer hardcoded LOC,CCODE,LOST and DAMAGED, they depend on default framework. Like is doing Bug 26323. Test plan : 1) Dont apply patch 2) Use sql to define some items lost and damaged 3) Look at checkouts table on a patron with a lot of checkouts 4) Apply patch 5) Look at checkouts table again 6) Check infos are the same : record level item type, item type, location, collection, lost, damaged 7) Check infos are the same in "Number of checkouts by item type"
(In reply to Katrin Fischer from comment #9) > Please check the fail from the QA script: > > FAIL svc/checkouts > FAIL critic > # Variables::ProhibitConditionalDeclarations: Got 2 violation(s). Oh indeed i see. Its a minor change : - my $type_for_stat = Koha::ItemTypes->find( $item_level_itypes ? $c->{itype} : $c->{itemtype} ); - my $itemtype = Koha::ItemTypes->find( $c->{itype} ); - my $recordtype = Koha::ItemTypes->find( $c->{itemtype} ); + my ( $itemtype, $recordtype, $type_for_stat ); + $itemtype = $itemtypes->{ $c->{itype} } if $c->{itype}; + $recordtype = $itemtypes->{ $c->{itemtype} } if $c->{itemtype}; + $type_for_stat = $item_level_itypes ? $itemtype : $recordtype; I replaced the patch
Created attachment 110379 [details] [review] Bug 26424: Better performance of svc/checkouts Ajax script svc/checkouts display checkouts of a patron. For each item, it fetches a Koha::ItemType object and a Koha::AuthorisedValues object for location,ccode,lost and damaged. For performance on huge number of checkouts : Item types should be fetch once before the loop. authorised values should call Koha::AuthorisedValues->get_description_by_koha_field because it uses a cache. I've tested with Plack : Without patch : 100 checkouts = 6 seconds 1000 checkouts = 60 seconds With patch : 100 checkouts = 5 seconds 1000 checkouts = 44 seconds Patch also changes the fact that authorised value categories are no longer hardcoded LOC,CCODE,LOST and DAMAGED, they depend on default framework. Like is doing Bug 26323. Test plan : 1) Dont apply patch 2) Use sql to define some items lost and damaged 3) Look at checkouts table on a patron with a lot of checkouts 4) Apply patch 5) Look at checkouts table again 6) Check infos are the same : record level item type, item type, location, collection, lost, damaged 7) Check infos are the same in "Number of checkouts by item type" Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 110429 [details] [review] Bug 26424: Better performance of svc/checkouts Ajax script svc/checkouts display checkouts of a patron. For each item, it fetches a Koha::ItemType object and a Koha::AuthorisedValues object for location,ccode,lost and damaged. For performance on huge number of checkouts : Item types should be fetch once before the loop. authorised values should call Koha::AuthorisedValues->get_description_by_koha_field because it uses a cache. I've tested with Plack : Without patch : 100 checkouts = 6 seconds 1000 checkouts = 60 seconds With patch : 100 checkouts = 5 seconds 1000 checkouts = 44 seconds Patch also changes the fact that authorised value categories are no longer hardcoded LOC,CCODE,LOST and DAMAGED, they depend on default framework. Like is doing Bug 26323. Test plan : 1) Dont apply patch 2) Use sql to define some items lost and damaged 3) Look at checkouts table on a patron with a lot of checkouts 4) Apply patch 5) Look at checkouts table again 6) Check infos are the same : record level item type, item type, location, collection, lost, damaged 7) Check infos are the same in "Number of checkouts by item type" Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Pushed to master for 20.11, thanks to everybody involved!
backported to 20.05.x for 20.05.05
enhancement, not backported to 19.11.x