[Checkins] SVN: Zope/branches/2.10/ Launchpad #348223: optimize catalog query by breaking out early from loop

Tres Seaver tseaver at palladion.com
Tue Mar 24 20:30:27 EDT 2009


Log message for revision 98341:
  Launchpad #348223: optimize catalog query by breaking out early from loop
  over indexes if the result set is already empty.
  
  

Changed:
  U   Zope/branches/2.10/doc/CHANGES.txt
  U   Zope/branches/2.10/lib/python/Products/ZCatalog/Catalog.py

-=-
Modified: Zope/branches/2.10/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.10/doc/CHANGES.txt	2009-03-25 00:28:22 UTC (rev 98340)
+++ Zope/branches/2.10/doc/CHANGES.txt	2009-03-25 00:30:26 UTC (rev 98341)
@@ -27,6 +27,9 @@
 
     Bugs fixed
 
+      - Launchpad #348223: optimize catalog query by breaking out early from
+        loop over indexes if the result set is already empty.
+
       - Launchpad ##332168: Connection.py: do not expose DB connection strings
         through exceptions
 

Modified: Zope/branches/2.10/lib/python/Products/ZCatalog/Catalog.py
===================================================================
--- Zope/branches/2.10/lib/python/Products/ZCatalog/Catalog.py	2009-03-25 00:28:22 UTC (rev 98340)
+++ Zope/branches/2.10/lib/python/Products/ZCatalog/Catalog.py	2009-03-25 00:30:26 UTC (rev 98341)
@@ -1,3 +1,4 @@
+
 ##############################################################################
 #
 # Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
@@ -478,7 +479,9 @@
             if r is not None:
                 r, u = r
                 w, rs = weightedIntersection(rs, r)
-        
+                if not rs:
+                   break       
+
         if rs is None:
             # None of the indexes found anything to do with the request
             # We take this to mean that the query was empty (an empty filter)



More information about the Checkins mailing list