Created
January 2, 2015 11:43
-
-
Save sebastianwebber/ebe4810bf03278624e31 to your computer and use it in GitHub Desktop.
Listando as 10 maiores tabelas no PostgreSQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH table_stats AS ( | |
SELECT | |
schemaname, | |
tablename, | |
pg_relation_size(schemaname || '.'|| tablename) as table_size, | |
(pg_total_relation_size(schemaname || '.'|| tablename) - pg_relation_size(schemaname || '.'|| tablename)) as index_size, | |
pg_total_relation_size(schemaname || '.'|| tablename) as total_size | |
FROM | |
pg_tables | |
) | |
SELECT | |
table_stats.schemaname, | |
table_stats.tablename, | |
pg_size_pretty(table_stats.table_size) as table_size, | |
pg_size_pretty(table_stats.index_size) as index_size, | |
pg_size_pretty(table_stats.total_size) as total_size | |
FROM | |
table_stats | |
WHERE | |
-- ajuste o filtro conforme sua necessidade! | |
table_stats.schemaname = 'public' | |
ORDER BY | |
table_stats.total_size desc, | |
table_stats.index_size desc, | |
table_stats.table_size desc | |
LIMIT 10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment