analyzeall.py
changeset 52 26121a8fe78b
parent 30 a8b7cd92f39f
child 83 515fadd3d286
--- a/analyzeall.py	Fri Oct 05 14:31:25 2012 +0200
+++ b/analyzeall.py	Tue Dec 11 10:49:42 2012 +0100
@@ -18,17 +18,20 @@
         self.parser.add_argument('-s', dest='schema', nargs='*', help='Schema filter')
         self.parser.add_argument('--vacuum', action='store_true', help='Call VACUUM ANALYZE')
         self.parser.add_argument('--full', action='store_true', help='Call VACUUM FULL ANALYZE')
+        self.parser.add_argument('--reindex', action='store_true', help='Call REINDEX TABLE')
         self.target_isolation_level = 'autocommit'
         self.init()
 
     def main(self):
         browser = pgbrowser.PgBrowser(self.pgm.get_conn('target'))
-        
+
         query_pattern = 'ANALYZE %s.%s;'
         if self.args.vacuum:
             query_pattern = 'VACUUM ANALYZE %s.%s;'
         if self.args.full:
             query_pattern = 'VACUUM FULL ANALYZE %s.%s;'
+        if self.args.reindex:
+            query_pattern = 'REINDEX TABLE %s.%s;'
 
         schema_list = self.args.schema
         if not schema_list:
@@ -39,7 +42,7 @@
             with self.pgm.cursor('target') as curs:
                 for table in tables:
                     query = query_pattern % (schema, table['name'])
-                    print(query)
+                    self.log.info(query)
                     curs.execute(query, [])