I haven't benchmarked this, but it seems really bad and easy to fix. To verify: Go to C4::Search:2119, notice the IF includes a query for a Koha::Patron object, and then for its related Koha::Patron::Category object. This is done for each item, on each record in the resultset WTF
Created attachment 89137 [details] [review] Bug 22813: remove repetitive queries inside two nested loops in searchResults This patch moves a query on Koha::Patrons and then the related Koha::Patron::Category that needlessly happens inside two nested loops (all items of all MARC records in the resultset). The Koha::Patron and Koha::Patron::Category are always the same as it is fetched from C4::Context->userenv each time. To test: - Run: $ kshell k$ prove t/db_dependent/Search.t => SUCCESS: Tests pass - Apply this patch - Run: k$ prove t/db_dependent/Search.t => SUCCESS: Tests still pass! - Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 89150 [details] [review] Bug 22813: remove repetitive queries inside two nested loops in searchResults This patch moves a query on Koha::Patrons and then the related Koha::Patron::Category that needlessly happens inside two nested loops (all items of all MARC records in the resultset). The Koha::Patron and Koha::Patron::Category are always the same as it is fetched from C4::Context->userenv each time. To test: - Run: $ kshell k$ prove t/db_dependent/Search.t => SUCCESS: Tests pass - Apply this patch - Run: k$ prove t/db_dependent/Search.t => SUCCESS: Tests still pass! - Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Created attachment 89151 [details] [review] Bug 22813: (follow-up) Add missing condition This patch restores a missing condition. $patron gets renamed to make it obvious that it related to the logged in user. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 89220 [details] [review] Bug 22813: remove repetitive queries inside two nested loops in searchResults This patch moves a query on Koha::Patrons and then the related Koha::Patron::Category that needlessly happens inside two nested loops (all items of all MARC records in the resultset). The Koha::Patron and Koha::Patron::Category are always the same as it is fetched from C4::Context->userenv each time. To test: - Run: $ kshell k$ prove t/db_dependent/Search.t => SUCCESS: Tests pass - Apply this patch - Run: k$ prove t/db_dependent/Search.t => SUCCESS: Tests still pass! - Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Liz Rea <wizzyrea@gmail.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 89221 [details] [review] Bug 22813: (follow-up) Add missing condition This patch restores a missing condition. $patron gets renamed to make it obvious that it related to the logged in user. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Well spotted! Passing QA
Awesome work all! Pushed to master for 19.05
Pushed to 18.11.x for 18.11.06
backported to 18.05.x for 18.05.13