Bug 23035

Summary: Intranet search is slow if thousands of items are in the biblios shown in the search results
Product: Koha Reporter: Joonas Kylmälä <joonas.kylmala>
Component: SearchingAssignee: Emmi Takkinen <emmi.takkinen>
Status: RESOLVED DUPLICATE QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: emmi.takkinen, fridolin.somers, jonathan.druart, nick, nugged
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26587
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28702
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28371
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 15262    
Attachments: Bug 23035: Use GetAuthorisedValues in transformMARCXML4XSLT

Description Joonas Kylmälä 2019-06-03 15:28:47 UTC
If you search on intranet for biblios that have in total thousands of items then then the search result will load very very slowly. The slowing down is linear with the amount of items in the bibs.

I already tracked this down to a GetAuthorisedValueDesc() call in C4/XSLT.pm. I will start working on a patch for this.
Comment 1 Jonathan Druart 2019-11-14 11:15:55 UTC
A quick and (hopefully) efficient change would be to replace the SELECT from authorised_values by a call to C4::Koha::GetAuthorisedValues (the cache is used there).
Comment 2 Andrii Nugged 2019-11-14 11:21:15 UTC Comment hidden (obsolete)
Comment 3 Emmi Takkinen 2021-06-22 08:31:15 UTC
(In reply to Jonathan Druart from comment #1)
> A quick and (hopefully) efficient change would be to replace the SELECT from
> authorised_values by a call to C4::Koha::GetAuthorisedValues (the cache is
> used there).

This does indeed improve search speed quite a bit. Tested this in test environment where biblios usually have from ten to thousand items and in most cases search time was halved. 

I think this change along side with syspref introduced in bug 28373 would be a good start to make search work faster.
Comment 4 Emmi Takkinen 2021-06-22 09:41:13 UTC
Created attachment 122275 [details] [review]
Bug 23035: Use GetAuthorisedValues in transformMARCXML4XSLT

Intranet search is slow if thousands of items are in the biblios
shown in the search results. Using GetAuthorisedValues (which uses
cache) instead of GetAuthorisedValueDesc in transformMARCXML4XSLT
significantly speeds up search time.

To test:
1. Add biblio or biblios with hundreds/thousands items.
2. Tab F12 and select 'Network' to view time spent on search.
3. Perform search, note how long search takes to finnish.
4. Apply patch.
5. Repeat search.
=> Note that search should now work faster.

Also prove t/db_dependent/XSLT.t

Sponsored-by: Koha-Suomi Oy
Comment 5 Nick Clemens 2021-08-25 15:44:19 UTC
GetAuthorisedValues returns an array, GetAuthorisedValueDesc returns a single value, so the patch needs a bit more.

To avoid caching/validation issues I proposed a solution on 28371 - can you take a look there?
Comment 6 Jonathan Druart 2021-10-13 07:10:56 UTC

*** This bug has been marked as a duplicate of bug 28371 ***