Wednesday, January 15, 2014

Postgresql schema sizes

0 comments
In order to get schema sizes of a large database, I used the following sql:

select schemaname, pg_size_pretty(sum(pg_table_size(schemaname||'.'||relname))::bigint) as s
from pg_stat_user_tables
group by schemaname

   schemaname   |    s  
----------------+---------
 schema1        | 11 GB
 temp           |   1088 kB
 schema2        | 51 GB
 schema3        | 179 GB
(4 rows)


Leave a Reply

Labels