Index: /trunk/ippToPsps/jython/scratchdb.py
===================================================================
--- /trunk/ippToPsps/jython/scratchdb.py	(revision 33181)
+++ /trunk/ippToPsps/jython/scratchdb.py	(revision 33182)
@@ -447,6 +447,11 @@
                self.logger.errorPair("Unable to delete " + region + " from", self.dvoDoneTable)
 
-        
-        return detectionCount - self.getRowCount(self.dvoDetectionTable)
+        finalCount = detectionCount - self.getRowCount(self.dvoDetectionTable)
+
+        # after a big delete, we should OPTIMIZE the table
+        self.logger.infoPair("Running OPTIMIZE on ", self.dvoDetectionTable)
+        if finalCount > 0: self.optimizeTable(self.dvoDetectionTable)
+
+        return finalCount
            
 
