Bug 17783: Optimize Koha::IssuingRules->get_effective_issuing_rule
authorLari Taskula <lari.taskula@jns.fi>
Thu, 15 Dec 2016 17:31:30 +0000 (19:31 +0200)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 23 Dec 2016 12:01:56 +0000 (12:01 +0000)
commit401f01125c23fe54e7697b0c22619c4d8e728b12
tree7b286e79b3f12ec7efddbb75650fb6ddf9281dbc
parent1ad30e63ea5e1d574d7cf82e86948ef501920d64
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.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Koha/IssuingRules.pm