GetCOinSBiblio is summoned three places in Koha so far: C4::VirtualShelves/Page.pm, opac/opac-search.pl and opac/opac-detail.pl. It takes in a biblionumber, then immediately calls GetMarcBiblio on that to get the record. This is a very expensive call. The kicker is that in 2 of the 3 contexts, we've ALREADY GOT the $record. We're pulling it in twice per title, and the number of titles we loop through is either OPACnumsearchresults or numsearchresults. The default of 20 has us making 40 calls to GetMarcBiblio... at several dozen milliseconds per call, that's a lot of time! If we change the GetCOinSBbiblio routine to take in a $record object instead, we save those calls on Lists and opac/opac-detail.pl. We'd just need to call GetMarcBiblio in the search results before calling GetCOinSBiblio... which is just moving the call from inside the subroutine to outside (no performance loss). Patch forthcoming.
Created attachment 6014 [details] [review] Proposed Patch This patch changes the GetCOinsBiblio subroutine to take a MARC record object (as returned from GetMarcBiblio) instead of a biblionumber. The first thing the subroutine did was GetMarcBiblio, and the $biblionumber passed was never used again. This subroutine was only used 3 places: opac/opac-search.pl, opac/opac-detail.pl, and C4/VirtualShelves/Page.pm. In the first and last cases, it was used in a loop. In the last two cases, a call to GetMarcBiblio had already been done. This is expensive, and we were doing it twice per record. For opac/opac-search.pl, the call to GetMarcBiblio was moved to just outside GetCOinSBiblio; this will not change the performance at all. But for opac/opac-detail.pl and C4/VirtualShelves/Page.pm, a redudant call to GetMarcBiblio is now avoided. To Test: 1. Enable COinSinOPACResults in system preferences. Perform a search in the OPAC. Verify that the COinS spans are showing up 2. View the detail record of one of the returned items. Confirm that the COinS span exists on the detail page. 3. View a list in the OPAC. Confirm that COinS spans are still showing up
Updating Version : This ENH will be for Koha 3.8
Bug versionned for master. entries will be made against rel_3_8 once the patch has been applied (see thread about that on koha-devel yesterday)
Created attachment 6174 [details] [review] Bug 7073: GetCOinSBiblio should take $record object, not biblionumber This patch changes the GetCOinsBiblio subroutine to take a MARC record object (as returned from GetMarcBiblio) instead of a biblionumber. The first thing the subroutine did was GetMarcBiblio, and the $biblionumber passed was never used again. This subroutine was only used 3 places: opac/opac-search.pl, opac/opac-detail.pl, and C4/VirtualShelves/Page.pm. In the first and last cases, it was used in a loop. In the last two cases, a call to GetMarcBiblio had already been done. This is expensive, and we were doing it twice per record. For opac/opac-search.pl, the call to GetMarcBiblio was moved to just outside GetCOinSBiblio; this will not change the performance at all. But for opac/opac-detail.pl and C4/VirtualShelves/Page.pm, a redudant call to GetMarcBiblio is now avoided. To Test: 1. Enable COinSinOPACResults in system preferences. Perform a search in the OPAC. Verify that the COinS spans are showing up 2. View the detail record of one of the returned items. Confirm that the COinS span exists on the detail page. 3. View a list in the OPAC. Confirm that COinS spans are still showing up Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Assigning to M. de Rooy for QA
QA: Code looks good. Should benefit performance. Well documented.
I checked with a grep that there were no other calls to GetCOinSBiblio, that's the case. Patch pushed, please test.
There have been no further reports of problems so I am marking this bug resolved.