Speed up sorted-related-holds query user/miker/hold-queue-speedup
authorMike Rylander <mrylander@gmail.com>
Fri, 8 Feb 2013 15:15:39 +0000 (10:15 -0500)
committerMike Rylander <mrylander@gmail.com>
Fri, 8 Feb 2013 15:15:39 +0000 (10:15 -0500)
commitecc771ef8e57266668e0ee692e2a1aa517b6ebf3
tree0b4831aea0ffecd7507f50f98e3c4e571750fa01
parent25f8ba16c8825e42c3a154b61b3ee0b0b4a6ab10
Speed up sorted-related-holds query

In several interfaces, we use a server side method which gathers statistics
about a hold: related holds, it's position in the (approximate) queue, the
estimated wait time, etc.  Within this method is a relatively complicated
json_query that returns the list of related, (FIFO-ish) sorted holds -- ones
that could be filled by a copy which could fill the hold in question.  This
commit restructures that query so as to make it faster when the list of
related holds is large, by removing duplicate (cartesian product, actually)
hold ids that were being fed into an INNER JOIN clause.

Testing shows a speed increase of 4x for related-hold queue of around 675
holds [~2s -> ~0.5s] on a relatively large Evergreen installation,
appropriately tuned.  The speed improvement gets larger with longer queues.
There is no observed decrease in speed for smaller queue sizes.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm