Descobrindo tamanho de colunas e tabelas no PostgreSQL
SELECT pg_size_pretty(sum(pg_column_size(coluna_1))) as coluna_1_size, pg_size_pretty(sum(pg_column_size(coluna_2))) as coluna_2_sizeFROM tabela
A query retornará algo assim:
coluna_1_size, coluna_2_size"163 kB" , "245 kB"
Descorbrindo tamanho de tabela, e índices (separadamente).
with tt as ( select * from ( values ('seu_schema.sua_tabela') ) tt(tb))select tb, pg_size_pretty (pg_indexes_size(tb)) index_size, pg_size_pretty (pg_relation_size(tb)) table_sizefrom tt;
Descobrindo tamanho de todas as tabelas e seus respectivos índices:
with tt as ( select table_schema||'.'||table_name as tb from information_schema.tables)select tb, pg_size_pretty (pg_indexes_size(tb)) index_size, pg_size_pretty (pg_relation_size(tb)) table_sizefrom tt;