Main Koha release repository https://koha-community.org
Find a file
Julian Maurice b64f96830b Bug 30004: Prevent TooMany from executing too many SQL queries
If a maximum number of checkouts allowed is defined in circulation
rules, C4::Circulation::TooMany will loop over all patron's checkouts.
When a patron has several hundreds of checkouts, it can really slow down
the checkout process by several seconds (or even tens of seconds)

This patch does two things:
- Always prefetch item data so that `$c->item` does not execute an
  additional SQL query at every iteration of the loop. Item data is
  always needed at the first line of the loop, so there is really no
  downside for doing this.
- Build the `@types` array only once, out of the checkouts loop. Since
  it does not depend at all on patron's checkouts data, it does not make
  sense to build it inside the loop.

Test plan:
1. Before applying the patch, create a patron with a lot of checkouts.
   I tested with 1000 checkouts, but the slowness should be noticeable
   with less.
2. Make sure you have a circulation rule (one that apply to your patron
   and the item(s) you will check out for testing) with a maximum number
   of checkouts allowed
3. Check out an item for the patron with a lot of checkouts. Measure the
   time it takes.
4. Apply the patch
5. Check out another item (or check in and then check out the same item
   used in step 3). Measure the time it takes and compare it to step 3.
   It should be faster now.
6. Run `prove t/db_dependent/Circulation/TooMany.t`

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-03-22 10:17:33 -10:00
acqui Bug 29771: Remove trivial cases 2022-03-08 23:03:34 -10:00
admin Bug 19532: Database and installer stuff 2022-03-14 22:45:50 -10:00
api Bug 30165: Make q parameter 'multi' 2022-03-22 10:17:33 -10:00
authorities Bug 29334: Do not apply defaultvalue to existing auth record 2021-11-15 12:38:39 +01:00
basket Bug 29844: Fix ->search occurrences 2022-02-09 15:36:23 -10:00
bin Bug 20582: Turn Koha into a Mojolicious application 2020-10-06 12:00:04 +02:00
C4 Bug 30004: Prevent TooMany from executing too many SQL queries 2022-03-22 10:17:33 -10:00
catalogue Bug 19532: (RM follow-up) Fix recalls.old is default 0 2022-03-15 00:31:32 -10:00
cataloguing Bug 25616: Uppercase hard coded lower case boolean operators for Elasticsearch 2022-02-24 14:35:36 -10:00
circ Bug 30155: Don't get items that can fillholds if there are no holds 2022-03-15 22:30:50 -10:00
clubs Bug 29859: Use iterator instead of as_list 2022-02-09 15:36:23 -10:00
course_reserves Bug 17600: Standardize our EXPORT_OK 2021-07-16 08:58:47 +02:00
debian Bug 19532: (QA follow-up) Add the cron jobs to the cron files 2022-03-14 22:45:52 -10:00
docs Revert "Bug 20076: Add Thibaud Guillot to contributors" 2022-01-13 22:12:53 -10:00
errors Bug 17600: Standardize our EXPORT_OK 2021-07-16 08:58:47 +02:00
etc Bug 18540: Update MARC21 biblio XSL file 2022-01-18 21:15:04 -10:00
ill Bug 29844: Fix ->search occurrences 2022-02-09 15:36:23 -10:00
installer Bug 27812: DBRev 21.12.00.019 2022-03-17 11:22:56 -10:00
Koha Bug 30181: (follow-up) Remove redundant queries and parameters 2022-03-22 10:17:33 -10:00
koha-tmpl Bug 30183: Fetch flatPickr instance prior to custom search definition 2022-03-22 10:17:33 -10:00
labels Bug 25616: (QA follow-up) Catch a case in labels/label-item-search.pl 2022-02-24 14:35:36 -10:00
lib/CGI/Session/Serialize Bug 17600: Standardize our EXPORT_OK 2021-07-16 08:58:47 +02:00
members Bug 17648: (QA follow-up) Restore imediate sending of the notice 2022-03-17 11:22:56 -10:00
misc Bug 19532: (RM follow-up) Fix recalls.old is default 0 2022-03-15 00:31:32 -10:00
offline_circ Bug 29255: Built-in offline circulation broken with SQL error 2021-11-15 12:38:39 +01:00
opac Bug 30214: (QA follow-up) Clarify code comment 2022-03-17 11:22:56 -10:00
patron_lists Bug 16446: Add ability to add patrons to list by borrowernumber 2021-10-21 12:24:04 +02:00
patroncards Bug 28576: Update the maximum size of an image. 2022-02-14 21:41:38 -10:00
plugins Bug 29931: Check cookie status before continuing 2022-03-15 22:30:50 -10:00
pos Bug 28481: (RM follow-up) formatting 2021-12-16 12:13:51 -10:00
recalls Bug 19532: (RM follow-up) Fix recalls.old is default 0 2022-03-15 00:31:32 -10:00
reports Bug 29767: SQL Koha reports and variable of database table << name|table_name>> 2022-02-09 22:01:37 -10:00
reserve Bug 19532: Recalls on intranet 2022-03-14 22:45:51 -10:00
reviews Bug 17600: Standardize our EXPORT_OK 2021-07-16 08:58:47 +02:00
rotating_collections Bug 17600: Standardize our EXPORT_OK 2021-07-16 08:58:47 +02:00
serials Bug 25616: Uppercase hard coded lower case boolean operators for Elasticsearch 2022-02-24 14:35:36 -10:00
services Bug 17600: Standardize our EXPORT_OK 2021-07-16 08:58:47 +02:00
skel
suggestion Bug 29859: Use iterator instead of as_list 2022-02-09 15:36:23 -10:00
svc Bug 29931: (follow-up) Fix svc/checkouts and return_claims too 2022-03-15 22:30:50 -10:00
t Bug 29915: (QA follow-up) Spelling 2022-03-22 10:17:33 -10:00
tags Bug 29469: (bug 17600 follow-up) Fix tag approval/rejection from staff 2021-11-16 15:49:22 +01:00
tmp/modified_authorities
tools Bug 19532: (RM follow-up) More use of system preference 2022-03-14 23:11:12 -10:00
virtualshelves Bug 29844: Fix ->search occurrences 2022-02-09 15:36:23 -10:00
xt Bug 28617: (QA follow-up) Restore FindBin in two places 2021-12-07 12:16:28 -10:00
.editorconfig Bug 27375: Set YAML file settings in .editorconfig 2021-11-03 15:40:52 +01:00
.eslintrc.json
.gitignore
.htaccess
.mailmap 21.11.00 - Update .mailmap 2021-11-26 12:26:22 +01:00
.perlcriticrc Bug 25898: Prohibit indirect object notation 2020-10-15 12:56:30 +02:00
.proverc.dist Bug 19821: Install sample data, ES mappings and Version syspref 2021-10-25 11:27:40 +02:00
.scss-lint.yml
about.pl Bug 28870: Move email address validation to a specific class method 2021-09-28 10:22:36 +02:00
app.psgi Bug 20582: Fix PSGI file when behind a reverse proxy 2020-10-06 12:00:04 +02:00
changelanguage.pl Bug 25898: Prohibit indirect object notation 2020-10-15 12:56:30 +02:00
cpanfile Bug 30252: lower version of 'Locale::XGettext::TT2' to 0.6 2022-03-15 22:30:50 -10:00
fix-perl-path.PL Bug 28606: Remove $DEBUG and $ENV{DEBUG} 2021-06-24 11:53:44 +02:00
gulpfile.js Bug 18984: Remove NORMARC support 2021-10-07 15:36:40 +02:00
help.pl Bug 17600: Standardize our EXPORT_OK 2021-07-16 08:58:47 +02:00
INSTALL Bug 26617: Update INSTALL file to include koha-testing-docker and Gitlab links 2020-10-15 12:56:30 +02:00
Koha.pm Bug 27812: DBRev 21.12.00.019 2022-03-17 11:22:56 -10:00
koha_perl_deps.pl Bug 17600: Standardize our EXPORT_OK 2021-07-16 08:58:47 +02:00
kohaversion.pl
LICENSE
mainpage.pl Bug 29020: Add link on the mainpage for users without admin access 2021-10-19 09:29:09 +02:00
Makefile.PL Bug 19532: Database and installer stuff 2022-03-14 22:45:50 -10:00
MANIFEST.SKIP
package.json Bug 27939: Update yarn.lock file 2021-03-16 12:04:06 +01:00
README
README.md Bug 27092: Remove note about "synced repo" from README.md 2020-11-25 16:31:58 +01:00
README.robots Bug 6411 add another example to README.robots 2011-07-05 14:48:05 +12:00
rewrite-config.PL Bug 28519: Put CGI::Session::Serialize::yamlxs in lib directory 2021-06-17 10:07:36 +02:00
yarn.lock Bug 27939: Update yarn.lock file 2021-03-16 12:04:06 +01:00

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

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

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