Last active
February 9, 2025 16:39
-
-
Save michaeltansg/4e177f0cb56cd78fdfc058c11a320135 to your computer and use it in GitHub Desktop.
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 AS table_name, | |
pg_size_pretty(pg_total_relation_size(format('%I.%I', schemaname, tablename))) AS total_size, | |
pg_size_pretty(pg_relation_size(format('%I.%I', schemaname, tablename))) AS table_size, | |
pg_size_pretty(pg_indexes_size(format('%I.%I', schemaname, tablename))) AS index_size | |
FROM pg_tables | |
WHERE schemaname NOT IN ('pg_catalog', 'information_schema') | |
ORDER BY pg_total_relation_size(format('%I.%I', schemaname, tablename)) DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment