The feature AllowRenewalIfOtherItemsAvailable can take a tremendous amount of processing for records with large numbers of holds and/or items. For example, for a record with 50 items and 100 holds we must call a series of subroutines 5000 times! The loop this processing takes place in has an outer loop of borrowers and an inner loop of items. However, two of the three subroutines only need an itemnumber. So, if we move the items loop to be the outer loop, we can 'cache' these subroutine calls and vastly improve the speed of the subroutine.
I was looking at v3.18. Looks like these speed improvements won't apply to master due to changes in IsAvailableForItemLevelRequest. I'll see if there is any way to improve this in master.
Created attachment 39808 [details] [review] Bug 14320 - WIP
My best effort looks like it offers little to no improvement. Closing out the bug.