Bugzilla – Attachment 58231 Details for
Bug 17783
Optimize Koha::IssuingRules->get_effective_issuing_rule
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17783: Optimize Koha::IssuingRules->get_effective_issuing_rule
Bug-17783-Optimize-KohaIssuingRules-geteffectiveis.patch (text/plain), 3.50 KB, created by
Lari Taskula
on 2016-12-15 17:44:24 UTC
(
hide
)
Description:
Bug 17783: Optimize Koha::IssuingRules->get_effective_issuing_rule
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2016-12-15 17:44:24 UTC
Size:
3.50 KB
patch
obsolete
>From 86921041b530b50c319fae3e54f588d37616f6bb Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@jns.fi> >Date: Thu, 15 Dec 2016 19:31:30 +0200 >Subject: [PATCH] Bug 17783: Optimize > Koha::IssuingRules->get_effective_issuing_rule > >This patch modifies method get_effective_issuing_rule in Koha::IssuingRules >aiming to optimize the search for matching issuing rule. > >Before this patch, in worst case scenario, we have had to make a SELECT query >eight times. This will have a negative impact on performance where-ever we need >to find matching issuing rule multiple times, if the search is not directly >matching an issuing rule on the first query. > >This patch makes get_effective_issuing_rule have a stable performance on both >best and worst case, whereas the old method was really fast on the best case >and really slow on the worst case. > >However, this patch slightly lowers the performance for best case, where matching >issuing rule is found instantly before (branchcode, categorycode and itemtype all >are specifically defined in issuing rules). For all other cases this patch offers >a performance improvement. > >To test: >1. Run t/db_dependent/Koha/IssuingRules.t and compare the results with previous > tests. >--- > Koha/IssuingRules.pm | 78 ++++++++-------------------------------------------- > 1 file changed, 11 insertions(+), 67 deletions(-) > >diff --git a/Koha/IssuingRules.pm b/Koha/IssuingRules.pm >index 3c588f7..c0c69be 100644 >--- a/Koha/IssuingRules.pm >+++ b/Koha/IssuingRules.pm >@@ -44,73 +44,17 @@ sub get_effective_issuing_rule { > my $itemtype = $params->{itemtype}; > my $branchcode = $params->{branchcode}; > >- my $rule = $self->find($params); >- return $rule if $rule; >- >- $rule = $self->find( >- { >- categorycode => $categorycode, >- itemtype => $default, >- branchcode => $branchcode >- } >- ); >- return $rule if $rule; >- >- $rule = $self->find( >- { >- categorycode => $default, >- itemtype => $itemtype, >- branchcode => $branchcode >- } >- ); >- return $rule if $rule; >- >- $rule = $self->find( >- { >- categorycode => $default, >- itemtype => $default, >- branchcode => $branchcode >- } >- ); >- return $rule if $rule; >- >- $rule = $self->find( >- { >- categorycode => $categorycode, >- itemtype => $itemtype, >- branchcode => $default >- } >- ); >- return $rule if $rule; >- >- $rule = $self->find( >- { >- categorycode => $categorycode, >- itemtype => $default, >- branchcode => $default >- } >- ); >- return $rule if $rule; >- >- $rule = $self->find( >- { >- categorycode => $default, >- itemtype => $itemtype, >- branchcode => $default >- } >- ); >- return $rule if $rule; >- >- $rule = $self->find( >- { >- categorycode => $default, >- itemtype => $default, >- branchcode => $default >- } >- ); >- return $rule if $rule; >- >- return; >+ my $rule = $self->search({ >+ categorycode => { 'in' => [ $categorycode, $default ] }, >+ itemtype => { 'in' => [ $itemtype, $default ] }, >+ branchcode => { 'in' => [ $branchcode, $default ] }, >+ }, { >+ order_by => { >+ -desc => ['branchcode', 'categorycode', 'itemtype'] >+ }, >+ rows => 1, >+ })->single; >+ return $rule; > } > > =head3 type >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17783
:
58228
|
58229
|
58230
|
58231
|
58268
|
58269
|
58270
|
58271
|
58300
|
58304
|
58309
|
58310
|
58311
|
58312
|
58313
|
58314