Skip to content

Instantly share code, notes, and snippets.

@nmandery
Created March 18, 2011 08:17
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 nmandery/875769 to your computer and use it in GitHub Desktop.
Save nmandery/875769 to your computer and use it in GitHub Desktop.
views to get relations sizes in postgresql
create or replace view public.size_schemata as
select table_schema,
pg_size_pretty(sum(pg_total_relation_size(table_schema || '."' || table_name || '"')::bigint)::bigint) As fulltblsize,
pg_size_pretty(sum(pg_relation_size(table_schema || '."' || table_name || '"')::bigint)::bigint) As justthetblsize
from information_schema.tables
where table_catalog = current_database()
group by table_schema
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment