[Koha-bugs] [Bug 17941] New: CanBookBeRenewed is very inefficient/slow

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Jan 19 14:28:25 CET 2017


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17941

            Bug ID: 17941
           Summary: CanBookBeRenewed is very inefficient/slow
 Change sponsored?: ---
           Product: Koha
           Version: master
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P5 - low
         Component: Hold requests
          Assignee: koha-bugs at lists.koha-community.org
          Reporter: boutrosboutrosboutros at gmail.com
        QA Contact: testopia at bugs.koha-community.org
                CC: gmcharlt at gmail.com

I started investigating why populating the checkout list in the patron view
sometimes took ages (minutes), and on occations even causing the system to
almost halt because of DB overload. It turned out that reason is calls to
C4::Circulation::CanBookBeRenewed. The critical factor is whether an item has
many holds on it, and if there are many items that can fill the hold.

Briefly looking at the code it seems obvious that the time spent grows
exponentially with the number of holds and items.

As one example, checking if an item with 111 holds (and 12 items on the biblio)
can be renewed takes around 25 sec and generates over 18,000 SQL queries. 

I can't help to think there must be some missed "early returns" opportunities
in the loops somewhere. For example, if there are more unfulfilled holds than
available items, can the item ever be renewed? If no, return before even begin
to calculate.. However, I know holds are full of complexities and things I
probably haven't thought about so I need to dig into the code more.

I would be very gratefull if anyone knowledgeable about this part of the code
could help me find some ways to optimize this!

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list