Bug 23387

Summary: Cache ClassSource
Product: Koha Reporter: Ian Walls <ian>
Component: Architecture, internals, and plumbingAssignee: Nick Clemens (kidclamp) <nick>
Status: RESOLVED FIXED QA Contact: Martin Renvoize (ashimema) <martin.renvoize>
Severity: normal    
Priority: P5 - low CC: lucas, martin.renvoize, nick, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00
Circulation function:
Attachments: Bug 23387: Add caching to C4::ClassSource
Bug 23387: Add caching to C4::ClassSource
Bug 23387: Add caching to C4::ClassSource

Description Ian Walls 2019-07-26 15:39:44 UTC
The data in the class_source table is not prone to frequent change, but is looked up for every biblio, biblioitem and item imported, resulting in needless DB calls and slowness.

Caching this relatively static data would provide a moderate performance boost to importing, particularly bulkmarcimport.pl
Comment 1 Katrin Fischer 2023-10-08 12:04:08 UTC
Still valid?
Comment 2 Nick Clemens (kidclamp) 2024-08-05 18:25:59 UTC
Created attachment 170076 [details] [review]
Bug 23387: Add caching to C4::ClassSource

These routines ultimately need to be moved to the Koha namespace, for now though,
we can reduce look ups during import and batch modification by caching the values
here for each request

To test:
1 - prove -v t/db_dependent/ClassSources.t
2 - Import some records with items, confirm cn_sort values correctly built
3 - Edit some items, confirm cn_Sort correclty built
Comment 3 Nick Clemens (kidclamp) 2024-08-05 18:27:44 UTC
(In reply to Katrin Fischer from comment #1)
> Still valid?

Yes, when migrating a library we noticed repeated lookups in the class sources tables from bulkmarcimport

We should go further and move to these to Koha namespace and cache at a deeper level, however, this will offer a benefit now and is a minor change
Comment 4 Phil Ringnalda 2024-08-23 17:57:24 UTC
Created attachment 170659 [details] [review]
Bug 23387: Add caching to C4::ClassSource

These routines ultimately need to be moved to the Koha namespace, for now though,
we can reduce look ups during import and batch modification by caching the values
here for each request

To test:
1 - prove -v t/db_dependent/ClassSources.t
2 - Import some records with items, confirm cn_sort values correctly built
3 - Edit some items, confirm cn_Sort correclty built

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Comment 5 Martin Renvoize (ashimema) 2024-08-23 21:17:09 UTC
Created attachment 170685 [details] [review]
Bug 23387: Add caching to C4::ClassSource

These routines ultimately need to be moved to the Koha namespace, for now though,
we can reduce look ups during import and batch modification by caching the values
here for each request

To test:
1 - prove -v t/db_dependent/ClassSources.t
2 - Import some records with items, confirm cn_sort values correctly built
3 - Edit some items, confirm cn_Sort correclty built

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 6 Martin Renvoize (ashimema) 2024-08-23 21:17:56 UTC
Clear code, well tested, noticeable improvement.

Passing QA
Comment 7 Katrin Fischer 2024-08-26 15:43:29 UTC
Pushed for 24.11!

Well done everyone, thank you!