Created
July 17, 2020 09:36
-
-
Save QuittyMR/997725bd5ea3fab1b6aa797771c09a31 to your computer and use it in GitHub Desktop.
Collect all entity sizes in a Postgres DB in high resolution
This file contains 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
SELECT pg_statio_user_tables.schemaname, | |
pg_statio_user_tables.relname, | |
pg_size_pretty(pg_total_relation_size(pg_statio_user_tables.relid::regclass)) AS total_size, | |
pg_size_pretty(pg_relation_size(pg_statio_user_tables.relid::regclass, 'main'::text)) AS relation_size_main, | |
pg_size_pretty(pg_relation_size(pg_statio_user_tables.relid::regclass, 'fsm'::text)) AS relation_size_fsm, | |
pg_size_pretty(pg_relation_size(pg_statio_user_tables.relid::regclass, 'vm'::text)) AS relation_size_vm, | |
pg_size_pretty(pg_relation_size(pg_statio_user_tables.relid::regclass, 'init'::text)) AS relation_size_init, | |
pg_size_pretty(pg_table_size(pg_statio_user_tables.relid::regclass)) AS table_size, | |
pg_size_pretty(pg_total_relation_size(pg_statio_user_tables.relid::regclass) - pg_relation_size(pg_statio_user_tables.relid::regclass)) AS external_size | |
FROM pg_statio_user_tables | |
ORDER BY (pg_total_relation_size(pg_statio_user_tables.relid::regclass)) DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment