Author: david
Date: Wed Jul  6 14:04:41 2011
New Revision: 9257

Log:
Optimization - use MySQL LIMIT to skip information objects.

Modified:
   trunk/lib/search/QubitSearch.class.php

Modified: trunk/lib/search/QubitSearch.class.php
==============================================================================
--- trunk/lib/search/QubitSearch.class.php      Wed Jul  6 13:51:45 2011        
(r9256)
+++ trunk/lib/search/QubitSearch.class.php      Wed Jul  6 14:04:41 2011        
(r9257)
@@ -119,18 +119,22 @@
     // index information objects
     if (-1 < $ioOffset)
     {
-      $informationObjects = QubitInformationObject::getAll();
-      $counter = count($informationObjects);      
+      $criteria = new Criteria;
+      QubitInformationObject::addSelectColumns($criteria);
+
+      if (0 < $ioOffset)
+      {
+        $criteria->setOffset($ioOffset);
+      }
+
+      $counter = intval(BasePeer::doCount(clone $criteria)->fetchColumn(0));
+      $informationObjects = QubitInformationObject::get($criteria);
+
       foreach ($informationObjects as $key => $informationObject)
       {
-        if (isset($ioOffset) && $key < $ioOffset)
+        if ($key == 0 && 0 < $ioOffset)
         {
-          if ($key == 0)
-          {
-            $this->getLogger()->log('Ignoring first '.$ioOffset.' information 
objects.');
-          }
-
-          continue;
+          $this->getLogger()->log('Ignoring first '.$ioOffset.' information 
objects.');
         }
 
         if (0 < count($languages = 
$this->getTranslatedLanguages($informationObject)))
@@ -141,7 +145,7 @@
           }
         }
 
-        $this->getLogger()->log('"'.$informationObject->__toString().'" 
inserted ('.round(microtime(true) - $start, 2).'s) ('.($key + 
1).'/'.$counter.')', $this->getName());
+        $this->getLogger()->log('"'.$informationObject->__toString().'" 
inserted ('.round(microtime(true) - $start, 2).'s) ('.($key + $ioOffset + 
1).'/'.$counter.')', $this->getName());
       }
     }
     else

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to