Go to file
Andrew Nugged 18ad5f5eea
Bug 24185: Make holds page fast when 'on shelf holds' set to 'If all unavailable'
When "reserve/request.pl -> C4/Reserves.pm::IsAvailableForItemLevelRequest" called many times with hundred of items and "on shelf holds" parameter set to "If all unavailable" for these items + patron, it goes slow.

It happens because in subloop it is checking if all items available so it is O(n^2) and it re-checks each time the same info for each item with repeating DB/data requests.

Fix:
The inner loop 1:1 picked out into separate subroutine and called outside of the loop, saving data in 'items_any_available' variable once, this variable passed to IsAvailableForItemLevelRequest to be used inside as the precalculated result.

This made algorithm O(n) instead of O(n^2) so there is noticeable speed increase.

How to reproduce:

1) on freshly installed kohadevbox create/import one book,
remember that biblionumber for later use it in down below,

2) add 100 items for that book for some library,

3) find some patron, that patron's card number we will
use as a borrower down below to open holds page,

4) check for the rule or set up a single circulation rule
in admin "/cgi-bin/koha/admin/smart-rules.pl",
that rule should match above book items/library/patron,
check that rule to have a non-zero number of holds (total, daily, count) allowed,
and, IMPORTANT: set up "On shelf holds allowed" to "If all unavailable",
("item level holds" doesn't matter).

5) open "Home > Catalog > THAT_BOOK > Place a hold on THAT_BOOK" page
("holds" tab), and enter patron code in the search field,
or you can create a direct link by yourself, for example, in my case it was:
/cgi-bin/koha/reserve/request.pl?biblionumber=4&findborrower=23529000686353

6) it should be pretty long page generation time on old code, densely increasing for every hundred items added. In the case of this solution, it's fast, and time increases a little only, linear.

I tested on my computer in VirtualBox for page generation times,
did 3-5 runs for same case to check if results are stable, and got such values:

(old code):
  100 items:    50 seconds
  200 items:   3.2 minutes
  300 items:   7.3 minutes

(version with fix):
  100 items:   4.4 seconds
  200 items:   7.5 seconds
  300 items:  10.4 seconds

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2020-03-25 09:40:58 +00:00
C4 Bug 24185: Make holds page fast when 'on shelf holds' set to 'If all unavailable' 2020-03-25 09:40:58 +00:00
Koha Bug 23590: DBIC Changes 2020-03-25 09:35:54 +00:00
acqui Bug 24276: Add FillWithDefaultValues call in neworderempty 2020-03-24 11:21:52 +00:00
admin Bug 23590: (QA follow-up) Fix some problems created by recent changes and updatedatabase statement 2020-03-25 09:35:24 +00:00
api/v1 Bug 24476: Rename autorenewal to autorenew_checkouts 2020-03-24 11:23:54 +00:00
authorities Bug 24545: Fix license statements 2020-02-24 13:31:26 +00:00
basket Bug 11529: Add templates for biblio title display. Unify display. 2019-08-05 15:03:19 +01:00
catalogue Bug 23463: Replace ModItem with Koha::Item->store 2020-03-23 09:26:30 +00:00
cataloguing Bug 22098: (QA follow-up) Improving documentation 2020-03-24 10:55:59 +00:00
circ Bug 24837: Rename selectbranchprinter.pl to set-library.pl 2020-03-24 11:07:22 +00:00
clubs Bug 23084: Replace grep {^$var$} with grep {$_ eq $var} 2020-02-17 10:44:45 +00:00
course_reserves Bug 21003: Removed warning and changed wording on add_items-step2.tt 2019-03-23 09:51:36 +00:00
debian Bug 24052: Add koha_xslt_security to koha-conf.xml 2020-03-24 10:42:23 +00:00
docs Koha 19.12 - Dobbie is a free elf... 2019-12-02 17:13:15 +00:00
errors Bug 24545: Fix license statements 2020-02-24 13:31:26 +00:00
etc Bug 24052: Add koha_xslt_security to koha-conf.xml 2020-03-24 10:42:23 +00:00
ill Bug 23112: Add circulation to ILL requests 2020-03-10 10:58:58 +00:00
installer Bug 23590: DBRev 19.12.00.055 2020-03-25 09:38:51 +00:00
koha-tmpl Bug 23590: (QA follow-up) Fix links to patron records (TT variable confusion) 2020-03-25 09:35:57 +00:00
labels Bug 24735: Remove QueryParser-related code 2020-03-02 11:13:03 +00:00
members Bug 24476: Allow patrons to opt out of auto-renewal 2020-03-24 11:23:47 +00:00
misc Bug 24476: Rename autorenewal to autorenew_checkouts 2020-03-24 11:23:54 +00:00
offline_circ Bug 23463: Replace ModItem with Koha::Item->store 2020-03-23 09:26:30 +00:00
opac Bug 24754: (QA follow-up) Add timestamp, remove 11th parameter 2020-03-25 09:32:48 +00:00
patron_lists Bug 19524: Use existing logged_in_user variable 2018-07-18 16:49:30 +00:00
patroncards Bug 24545: Fix license statements 2020-02-24 13:31:26 +00:00
plugins Bug 23975: (follow-up) Don't rely on save_to being present 2020-03-03 09:19:04 +00:00
pos Bug 24492: (RM follow-up) Redirect to correct page after cashup 2020-03-05 14:16:58 +00:00
reports Bug 20443: Use search_with_library_limits for attribute types 2020-03-23 13:49:22 +00:00
reserve Bug 24185: Make holds page fast when 'on shelf holds' set to 'If all unavailable' 2020-03-25 09:40:58 +00:00
reviews Bug 18789: Send Koha::Patron object to the templates 2018-02-16 13:03:58 -03:00
rotating_collections Bug 21500: Remove warnings in rotating collections 2018-10-09 15:02:45 +00:00
serials Bug 23463: Replace ModItem with Koha::Item->store 2020-03-23 09:26:30 +00:00
services Bug 20019: use Modern::Perl in misc perl scripts 2018-02-05 09:47:08 -03:00
skel Bug 11078: Add locking to rebuild_zebra 2014-02-28 22:21:41 +00:00
suggestion Bug 23590: Create a separate template notice NOTIFY_MANAGER 2020-03-25 09:35:46 +00:00
svc Bug 23463: Replace ModItem with Koha::Item->store 2020-03-23 09:26:30 +00:00
t Bug 24185: Make holds page faster: Preparatory refactoring 2020-03-25 09:40:39 +00:00
tags Bug 11529: Add templates for biblio title display. Unify display. 2019-08-05 15:03:19 +01:00
tmp/modified_authorities changing DO_NOT_REMOVE to README.txt 2007-10-21 19:14:41 -05:00
tools Bug 20443: Use search_with_library_limits for attribute types 2020-03-23 13:49:22 +00:00
virtualshelves Bug 23084: Replace grep {^$var$} with grep {$_ eq $var} 2020-02-17 10:44:45 +00:00
xt Bug 24583: adjust xt/sample_notices.t 2020-03-09 15:19:01 +00:00
.editorconfig Bug 24774: Set JSON indentation of 2 spaces in .editorconfig 2020-03-19 09:24:52 +00:00
.eslintrc.json Bug 23834: Add default ESLint configuration 2019-11-03 08:02:39 +00:00
.gitignore Bug 20427: Convert OPAC LESS to SCSS 2018-08-09 15:17:07 +00:00
.htaccess Fix file permissions: if it is not a script, it should not be executable. 2010-04-16 00:40:34 -04:00
.mailmap Update mailmap - Jonathan Druart 2017-06-21 12:42:19 -03:00
.scss-lint.yml Bug 21237: Clean up staff client SCSS 2018-08-24 16:23:25 +00:00
INSTALL Bug 17626: Remove existing install instructions and link to the wiki pages instead 2016-11-22 11:29:07 +00:00
Koha.pm Bug 23590: DBRev 19.12.00.055 2020-03-25 09:38:51 +00:00
LICENSE Bug 9440 - update Koha's LICENSE file from GPL2 to GPL3 2013-02-12 08:52:10 -05:00
MANIFEST.SKIP Bug 9546 : Updating make manifest tardist 2013-02-06 23:54:46 -05:00
Makefile.PL Bug 19735: Move Perl deps definitions into a cpanfile 2020-02-12 16:33:02 +00:00
README Bug 9440 - update Koha's LICENSE file from GPL2 to GPL3 2013-02-12 08:52:10 -05:00
README.md Bug 15465: Fix typo in bugs.k-c.org 2017-05-26 11:45:31 -03:00
README.robots Bug 6411 add another example to README.robots 2011-07-05 14:48:05 +12:00
about.pl Bug 24735: Remove QueryParser-related code 2020-03-02 11:13:03 +00:00
changelanguage.pl Bug 21299: (QA follow-up) Rename module and subroutine 2018-11-07 21:52:17 +00:00
cpanfile Bug 24573: Add missing dependencies to cpanfile 2020-03-06 09:58:54 +00:00
fix-perl-path.PL Bug 9978: (followup) Replace license header with the correct license (GPLv3+) 2015-04-20 09:59:43 -03:00
gulpfile.js Bug 21751: Replace fixFloat with HC-sticky to fix Chrome display 2019-02-04 14:13:35 +00:00
help.pl Bug 19817: Use the language from the interface if valid 2018-09-06 17:32:28 +00:00
koha_perl_deps.pl Bug 24545: Fix license statements 2020-02-24 13:31:26 +00:00
kohaversion.pl Bug 13758: Move the Koha version from kohaversion.pl 2015-05-07 11:39:04 -03:00
mainpage.pl Bug 21907: Fix article requests count for non-superlibrarians 2019-02-04 14:50:40 +00:00
package.json Bug 23025: security vulnerability detected in fstream < 1.0.12 defined in yarn.lock 2019-11-27 11:30:17 +00:00
rewrite-config.PL Bug 17851: Add elasticsearch config to koha-conf.xml 2019-10-07 14:09:10 +01:00
yarn.lock Bug 23025: Update yarn.lock 2019-11-27 11:30:17 +00:00

README.md

Koha is a free software integrated library system (ILS).

Koha is distributed under the GNU GPL version 3 or later.

Note: This is a synced mirror of the official Koha repo.

Note: Koha does not accept pull requests from git hosting sites.

Note: This project has its own bug tracker, to report a bug or submit a patch visit http://bugs.koha-community.org.

For guidelines on submitting patches for Koha please visit https://wiki.koha-community.org/wiki/SubmitingAPatch

The developers handbook can be found at https://wiki.koha-community.org/wiki/Developer_handbook

http://koha-community.org/

Koha Logo