From: miker Date: Tue, 19 Apr 2011 19:56:04 +0000 (+0000) Subject: Use top level join instead of subquery in hold queue position query X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3afcc0dba45400618a3e5566d92c8d032375d369;p=contrib%2FConifer.git Use top level join instead of subquery in hold queue position query This is more readily optimized by the Postgres planer. Note also, for very large data sets (lots of holds, on the order of 100k+ active), the following is also advised: ALTER TABLE action.hold_copy_map alter column target_copy SET statistics 500, alter column hold set statistics 500; ANALYZE action.hold_copy_map; This gives the planner better data about the hold-copy-map n-distinct. git-svn-id: svn://svn.open-ils.org/ILS/trunk@20221 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index 696cd06859..6ce8691907 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -1065,7 +1065,19 @@ sub retrieve_hold_queue_status_impl { # fetch cut_in_line and request_time since they're in the order_by # and we're asking for distinct values select => {ahr => ['id', 'cut_in_line', 'request_time']}, - from => { ahr => 'ahcm' }, + from => { + ahr => { + 'ahcm' => { + join => { + 'ahcm2' => { + 'class' => 'ahcm', + 'field' => 'target_copy', + 'fkey' => 'target_copy' + } + } + } + } + }, order_by => [ { "class" => "ahr", @@ -1078,15 +1090,7 @@ sub retrieve_hold_queue_status_impl { ], distinct => 1, where => { - '+ahcm' => { - target_copy => { - in => { - select => {ahcm => ['target_copy']}, - from => 'ahcm', - where => {hold => $hold->id} - } - } - } + '+ahcm2' => { hold => $hold->id } } });