Skip to content

Instantly share code, notes, and snippets.

@stultus
Last active December 17, 2019 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stultus/8a5423e3795864a0cda153d945543c53 to your computer and use it in GitHub Desktop.
Save stultus/8a5423e3795864a0cda153d945543c53 to your computer and use it in GitHub Desktop.
select 10 most largest postgress tables
select schemaname as table_schema,
relname as table_name,
pg_size_pretty(pg_total_relation_size(relid)) as total_size,
pg_size_pretty(pg_relation_size(relid)) as data_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,
pg_relation_size(relid) desc
limit 10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment