# HG changeset patch # User Radek Brich # Date 1338456521 -7200 # Node ID d3593869d62493512aa59e4f9cc27cfea931b656 # Parent 5b0eb4b119400047a789bd3ed4ad4c84f278c21c Update bigtables tool: scan all schemas. diff -r 5b0eb4b11940 -r d3593869d624 bigtables.py --- a/bigtables.py Wed May 23 16:02:53 2012 +0200 +++ b/bigtables.py Thu May 31 11:28:41 2012 +0200 @@ -11,8 +11,17 @@ def main(self): browser = pgbrowser.PgBrowser(self.pgm.get_conn('target')) - tables = browser.list_tables() - for table in sorted(tables, reverse=True, key=lambda x: x['size'])[:20]: + # scan all tables from all shemas, remember names and sizes + all_tables = [] + schemas = browser.list_schemas() + for schema in schemas: + tables = browser.list_tables(schema['name']) + for table in tables: + table_name = '%s.%s' % (schema['name'], table['name']) + all_tables.append({'name': table_name, 'size': table['size']}) + + # print names and sizes of 20 largest tables + for table in sorted(all_tables, reverse=True, key=lambda x: x['size'])[:20]: print(prettysize.prettysize_short(table['size']).rjust(8), table['name'], sep=' ')