Skip to content

Instantly share code, notes, and snippets.

@mgurov
Created May 16, 2018 13:18
Show Gist options
  • Save mgurov/ccc87c3dbd2c2db88b59860b016bd9f2 to your computer and use it in GitHub Desktop.
Save mgurov/ccc87c3dbd2c2db88b59860b016bd9f2 to your computer and use it in GitHub Desktop.
select
nspname || '.' || relname as "relation",
pg_size_pretty(
pg_relation_size(C.oid)
) as "size",
to_char(round( pg_relation_size(C.oid) /(
select
sum( pg_relation_size( C.oid ) ) as "totalsize"
from
pg_class C
) * 100.0, 2), '90.00' ) percentage
from
pg_class C left join pg_namespace N on
(
N.oid = C.relnamespace
)
where
nspname not in(
'pg_catalog',
'information_schema'
)
and pg_relation_size(C.oid) > 100000
order by
pg_relation_size(C.oid) desc limit 50;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment