Created
January 30, 2023 10:16
-
-
Save evilz/9216eb30c527c152c69c5b19cb8e0822 to your computer and use it in GitHub Desktop.
PG table Size
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 current_database() as database, | |
pg_size_pretty(total_database_size) as total_database_size, | |
schema_name, | |
table_name, | |
pg_size_pretty(total_table_size) as total_table_size, | |
pg_size_pretty(table_size) as table_size, | |
pg_size_pretty(index_size) as index_size | |
from ( select table_name, | |
table_schema as schema_name, | |
pg_database_size(current_database()) as total_database_size, | |
pg_total_relation_size(table_name) as total_table_size, | |
pg_relation_size(table_name) as table_size, | |
pg_indexes_size(table_name) as index_size | |
from information_schema.tables | |
where table_schema=current_schema() | |
order by total_table_size | |
) as sizes; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment