32 for table in tables: |
32 for table in tables: |
33 table_name = '%s.%s' % (schema['name'], table['name']) |
33 table_name = '%s.%s' % (schema['name'], table['name']) |
34 indexes = browser.list_indexes(table['name'], schema['name']) |
34 indexes = browser.list_indexes(table['name'], schema['name']) |
35 for index in indexes: |
35 for index in indexes: |
36 all_indexes.append({'name': index['name'], 'table': table_name, 'size': index['size']}) |
36 all_indexes.append({'name': index['name'], 'table': table_name, 'size': index['size']}) |
37 all_tables.append({'name': table_name, 'size': table['size'], 'indexes': indexes}) |
37 size_with_indexes = table['size'] + sum(index['size'] for index in indexes) |
|
38 all_tables.append({'name': table_name, 'size': table['size'], 'indexes': indexes, 'size_with_indexes': size_with_indexes}) |
38 |
39 |
39 # print names and sizes of 20 largest tables |
40 # print names and sizes of 20 largest tables |
40 for table in sorted(all_tables, reverse=True, key=lambda x: x['size'])[:self.args.limit]: |
41 for table in sorted(all_tables, reverse=True, key=lambda x: x['size_with_indexes'])[:self.args.limit]: |
41 size_of_indexes = sum(index['size'] for index in table['indexes']) |
42 print(highlight(1) + prettysize_short(table['size_with_indexes'], trailing_zeros=True).rjust(8) + highlight(0), |
42 print(highlight(1) + prettysize_short(table['size'] + size_of_indexes, trailing_zeros=True).rjust(8) + highlight(0), |
|
43 '(total)'.ljust(8), |
43 '(total)'.ljust(8), |
44 highlight(1) + table['name'] + highlight(0), sep=' ') |
44 highlight(1) + table['name'] + highlight(0), sep=' ') |
45 if self.args.details: |
45 if self.args.details: |
46 print(prettysize_short(table['size'], trailing_zeros=True).rjust(8), |
46 print(prettysize_short(table['size'], trailing_zeros=True).rjust(8), |
47 '(data)'.ljust(8), sep=' ') |
47 '(data)'.ljust(8), sep=' ') |