SELECT n.nspname AS schema_name, c.relname AS table_name, pg_size_pretty(pg_total_relation_size(c.oid)) AS total_size, pg_size_pretty(pg_table_size(c.oid)) AS table_only_size, -- Size of the table excluding indexes but including TOAST pg_size_pretty(pg_indexes_size(c.oid)) AS indexes_size, pg_size_pretty(pg_total_relation_size(reltoastrelid)) AS toast_size -- Explicit TOAST table size FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'r' -- 'r' for relation (tables) AND n.nspname NOT IN ('pg_catalog', 'information_schema') -- Exclude system schemas AND n.nspname !~ '^pg_toast' -- Exclude explicit TOAST schemas (though pg_total_relation_size covers it) ORDER BY pg_total_relation_size(c.oid) DESC;