Last active
March 14, 2019 10:35
-
-
Save dac73/9f54dd1b075b30254c70e9a2f6ab8438 to your computer and use it in GitHub Desktop.
Postgres
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
| -- table sizes real/sys | |
| SELECT | |
| relname as "Table", | |
| pg_size_pretty(pg_total_relation_size(relid)) As "Size", | |
| pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) as "External Size" | |
| FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC; | |
| -- more details on size | |
| SELECT | |
| relname as "Table", | |
| pg_size_pretty(pg_total_relation_size(relid)) As "Table+Index", | |
| pg_size_pretty(pg_total_relation_size(relid) - pg_table_size(relid)) as "IndexSize", pg_size_pretty(pg_table_size(relid)) as "Table size" | |
| FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC; | |
| -- DB size | |
| select pg_size_pretty( pg_database_size('DB-NAME')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment