dbsize.sql (450B)
1 create temporary view sizes as 2 select table_name as n, 3 pg_relation_size(quote_ident(table_name)) / 1024.0 / 1024.0 as s_tbl, 4 pg_indexes_size(quote_ident(table_name)) / 1024.0 / 1024.0 as s_idx 5 from information_schema.tables 6 where table_schema = 'public'; 7 8 9 select n, s_tbl, s_idx, s_tbl + s_idx from sizes where (s_tbl) != 0 10 order by (s_tbl + s_idx); 11 12 select sum(s_tbl), sum(s_idx), sum(s_tbl + s_idx) from sizes where s_tbl != 0;