[open-ils-commits] r20219 - branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Circ (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Apr 19 15:51:31 EDT 2011


Author: miker
Date: 2011-04-19 15:51:26 -0400 (Tue, 19 Apr 2011)
New Revision: 20219

Modified:
   branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
Log:
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.



Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm	2011-04-19 17:56:49 UTC (rev 20218)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm	2011-04-19 19:51:26 UTC (rev 20219)
@@ -1063,7 +1063,19 @@
         # 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",
@@ -1076,15 +1088,7 @@
         ],
         distinct => 1,
         where => {
-            '+ahcm' => {
-                target_copy => {
-                    in => {
-                        select => {ahcm => ['target_copy']},
-                        from   => 'ahcm',
-                        where  => {hold => $hold->id}
-                    } 
-                } 
-            }
+            '+ahcm2' => { hold => $hold->id }
         }
     });
 



More information about the open-ils-commits mailing list