Is there an easy way to get the total size of all tables including partitions? I've written this query for Greenplum, but it's a bit round-a-bout:
with part_sz as (
select ts.sotdschemaname sch
, coalesce(ps.sopaidparenttablename,ts.sotdtablename) tbl
, coalesce(ps.sopaidpartitiontablesize,ts.sotdsize) part_size
from gp_toolkit.gp_size_of_table_disk ts
left join gp_toolkit.gp_size_of_partition_and_indexes_disk ps
on ts.sotdschemaname = ps.sopaidpartitionschemaname
and ts.sotdtablename = ps.sopaidpartitiontablename
)
, tbl_sz as (
select sch, tbl, sum(part_size) total_size
from part_sz
group by sch, tbl
)
select sch, tbl, total_size
from tbl_sz
order by total_size desc
Greenplum is built on Postgres 8.2, so something using that feature set would be ideal, but feel free to post anything using newer Postgres versions for the benefit of other readers.