Skip to content

Instantly share code, notes, and snippets.

@onhernandes
Last active June 13, 2022 16:12
Show Gist options
  • Save onhernandes/e91fdb2a81b0c7dc5fdef98d8b1766a1 to your computer and use it in GitHub Desktop.
Save onhernandes/e91fdb2a81b0c7dc5fdef98d8b1766a1 to your computer and use it in GitHub Desktop.
List tables ordering by their size on postgresql
-- copied from https://dataedo.com/kb/query/postgresql/list-of-tables-by-their-size
select schemaname as table_schema,
relname as table_name,
pg_size_pretty(pg_relation_size(relid)) as data_size
from pg_catalog.pg_statio_user_tables
order by pg_relation_size(relid) desc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment