analyzeall.py
changeset 30 a8b7cd92f39f
parent 28 27fc0504663d
child 52 26121a8fe78b
equal deleted inserted replaced
29:8636719a30f6 30:a8b7cd92f39f
     1 #!/usr/bin/env python3.2
     1 #!/usr/bin/env python3.2
       
     2 """
       
     3 analyzeall
       
     4 
       
     5 Analyze/vacuum all tables in selected schemas.
       
     6 See also "VACUUM ANALYZE VERBOSE;" query.
       
     7 Unlike that, this program skips pg_catalog etc.
       
     8 
       
     9 """
     2 
    10 
     3 from pgtoolkit import pgbrowser, toolbase
    11 from pgtoolkit import pgbrowser, toolbase
     4 from pgtoolkit.highlight import highlight
    12 from pgtoolkit.highlight import highlight
     5 
    13 
     6 
    14 
     8     def __init__(self):
    16     def __init__(self):
     9         toolbase.SimpleTool.__init__(self, name='analyzeall', desc='Analyze all tables.')
    17         toolbase.SimpleTool.__init__(self, name='analyzeall', desc='Analyze all tables.')
    10         self.parser.add_argument('-s', dest='schema', nargs='*', help='Schema filter')
    18         self.parser.add_argument('-s', dest='schema', nargs='*', help='Schema filter')
    11         self.parser.add_argument('--vacuum', action='store_true', help='Call VACUUM ANALYZE')
    19         self.parser.add_argument('--vacuum', action='store_true', help='Call VACUUM ANALYZE')
    12         self.parser.add_argument('--full', action='store_true', help='Call VACUUM FULL ANALYZE')
    20         self.parser.add_argument('--full', action='store_true', help='Call VACUUM FULL ANALYZE')
       
    21         self.target_isolation_level = 'autocommit'
    13         self.init()
    22         self.init()
    14 
    23 
    15     def main(self):
    24     def main(self):
    16         browser = pgbrowser.PgBrowser(self.pgm.get_conn('target'))
    25         browser = pgbrowser.PgBrowser(self.pgm.get_conn('target'))
    17         
    26