Bug 20919

Summary: A Zebra query is done for each item when opening a record detail page
Product: Koha Reporter: Hugo Agud <hagud>
Component: Staff interfaceAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P4 CC: cslone, dali.bouazizi, fridolin.somers, gmcharlt, jonathan.druart, m.de.rooy, martin.renvoize, mtj, nick, tomascohen
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 20919: Remove unecessary search calls on the biblio detail page
Bug 20919: Remove unecessary search calls on the biblio detail page
Bug 20919: Remove unecessary search calls on the biblio detail page
Bug 20919: Remove unecessary search calls on the biblio detail page

Description Hugo Agud 2018-06-12 14:31:10 UTC
We have figured out that koha launch a zebra query for each item of a record, if the record have few items no problem, but if the record has hundreds of items, the time to display goes easily over 30 seconds.

we have checked on a fresh install on debian jessie 8 with koha 17.11.6 and 18.05

the file  zebra-output.log becomes huge

We have checked from intranet interface
Comment 1 Jonathan Druart 2018-06-14 14:37:59 UTC
Created attachment 76057 [details] [review]
Bug 20919: Remove unecessary search calls on the biblio detail page

There is a countanalytics flag that is set for items used in analytical
biblio records. This flag is only used in the template when 'analyze'
has been passed to the script.
In order to avoid unecessary search calls (1 per item), $analyse must be
tested.

Test plan:
0. Do not apply the patch
1. tail -f /var/log/koha/kohadev/zebra-output.log
2. Hit a bibliographic record detail page with several items
3. Notice that the log has 1 line per item:
  11:30:36-14/06 zebrasrv(32) [warn] ir_session (exception)
4. Apply the patch
5. Hit the page again
6. There is nothing in the zebra log file

If you are familiar with analytic records, confirm that you are not
allowed to remove an item that is used in analytical biblio records.
Comment 2 Hugo Agud 2018-06-15 08:01:16 UTC
Created attachment 76090 [details] [review]
Bug 20919: Remove unecessary search calls on the biblio detail page

There is a countanalytics flag that is set for items used in analytical
biblio records. This flag is only used in the template when 'analyze'
has been passed to the script.
In order to avoid unecessary search calls (1 per item), $analyse must be
tested.

Test plan:
0. Do not apply the patch
1. tail -f /var/log/koha/kohadev/zebra-output.log
2. Hit a bibliographic record detail page with several items
3. Notice that the log has 1 line per item:
  11:30:36-14/06 zebrasrv(32) [warn] ir_session (exception)
4. Apply the patch
5. Hit the page again
6. There is nothing in the zebra log file

If you are familiar with analytic records, confirm that you are not
allowed to remove an item that is used in analytical biblio records.

Signed-off-by: Hugo Agud <hagud@orex.es>
Comment 3 Jonathan Druart 2018-07-11 14:20:25 UTC
Created attachment 76862 [details] [review]
Bug 20919: Remove unecessary search calls on the biblio detail page

There is a countanalytics flag that is set for items used in analytical
biblio records. This flag is only used in the template when 'analyze'
has been passed to the script.
In order to avoid unecessary search calls (1 per item), $analyse must be
tested.

Test plan:
0. Do not apply the patch
1. tail -f /var/log/koha/kohadev/zebra-output.log
2. Hit a bibliographic record detail page with several items
3. Notice that the log has 1 line per item:
  11:30:36-14/06 zebrasrv(32) [warn] ir_session (exception)
4. Apply the patch
5. Hit the page again
6. There is nothing in the zebra log file

If you are familiar with analytic records, confirm that you are not
allowed to remove an item that is used in analytical biblio records.

Signed-off-by: Hugo Agud <hagud@orex.es>
Comment 4 Martin Renvoize 2018-07-12 10:18:19 UTC
Created attachment 76881 [details] [review]
Bug 20919: Remove unecessary search calls on the biblio detail page

There is a countanalytics flag that is set for items used in analytical
biblio records. This flag is only used in the template when 'analyze'
has been passed to the script.
In order to avoid unecessary search calls (1 per item), $analyse must be
tested.

Test plan:
0. Do not apply the patch
1. tail -f /var/log/koha/kohadev/zebra-output.log
2. Hit a bibliographic record detail page with several items
3. Notice that the log has 1 line per item:
  11:30:36-14/06 zebrasrv(32) [warn] ir_session (exception)
4. Apply the patch
5. Hit the page again
6. There is nothing in the zebra log file

If you are familiar with analytic records, confirm that you are not
allowed to remove an item that is used in analytical biblio records.

Signed-off-by: Hugo Agud <hagud@orex.es>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 5 Martin Renvoize 2018-07-12 10:18:59 UTC
Another fairly trivial but important improvement. All appears to work well and I can't find any regressions.

Passing QA
Comment 6 Nick Clemens 2018-07-13 11:25:15 UTC
Awesome work all!

Pushed to master for 18.11
Comment 7 Martin Renvoize 2018-07-15 19:04:27 UTC
Pushed to 18.05.x for 18.05.02
Comment 8 Fridolin Somers 2018-07-30 12:37:53 UTC
Pushed to 17.11.x for 17.11.09
Comment 9 Fridolin Somers 2018-07-30 12:38:14 UTC
Nice catch Hugo ;)