denrepo

PostgreSQLStorage

Largest tables with index size

Top 20 tables in the current database by total size, split into heap and index.

Not yet verified. How scripts are tested

b-pg-tables.sql
1SELECT n.nspname AS schema_name, c.relname AS table_name,2       pg_size_pretty(pg_total_relation_size(c.oid)) AS total_size,3       pg_size_pretty(pg_relation_size(c.oid)) AS table_size,4       pg_size_pretty(pg_indexes_size(c.oid)) AS index_size,5       c.reltuples::bigint AS est_rows6FROM pg_class c7JOIN pg_namespace n ON n.oid = c.relnamespace8WHERE c.relkind IN ('r', 'p')9  AND n.nspname NOT IN ('pg_catalog', 'information_schema')10ORDER BY pg_total_relation_size(c.oid) DESC11LIMIT 20;

Paste it into your query tool.

Open in denrepo

More PostgreSQL scripts: Storage