[PostgreSQL] - Listando as 10 maiores tabelas no PostgreSQL
Para listar as maiores tabelas do seu banco de dados, utilize a consulta abaixo:
WITHtable_statsAS(SELECTschemaname,tablename,pg_relation_size(schemaname||'.'||tablename)astable_size,(pg_total_relation_size(schemaname||'.'||tablename)-pg_relation_size(schemaname||'.'||tablename))asindex_size,pg_total_relation_size(schemaname||'.'||tablename)astotal_sizeFROMpg_tables)SELECTtable_stats.schemaname,table_stats.tablename,pg_size_pretty(table_stats.table_size)astable_size,pg_size_pretty(table_stats.index_size)asindex_size,pg_size_pretty(table_stats.total_size)astotal_sizeFROMtable_statsWHERE-- ajuste o filtro conforme sua necessidade!table_stats.schemaname='public'ORDERBYtable_stats.total_sizedesc,table_stats.index_sizedesc,table_stats.table_sizedescLIMIT10;
Nenhum comentário:
Postar um comentário