Created
September 15, 2021 15:23
-
-
Save tammoippen/33bc85602fcbc2280097fabb040c26ed to your computer and use it in GitHub Desktop.
List the size of all tables in postgresql
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 | |
schemaname, | |
tablename, | |
PG_SIZE_PRETTY( | |
PG_TOTAL_RELATION_SIZE(schemaname || '.' || tablename) | |
) AS tablesize | |
FROM | |
pg_catalog.pg_tables | |
WHERE | |
schemaname NOT IN ('pg_catalog', 'information_schema') | |
ORDER BY | |
PG_TOTAL_RELATION_SIZE(schemaname || '.' || tablename) DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment