Skip to content

Instantly share code, notes, and snippets.

@martinciu
Created July 31, 2012 19:10
Show Gist options
  • Save martinciu/3219616 to your computer and use it in GitHub Desktop.
Save martinciu/3219616 to your computer and use it in GitHub Desktop.
SELECT c.relname AS Name,
pg_size_pretty(pg_relation_size(c.relname::text)) AS Data,
pg_size_pretty(pg_total_relation_size(c.relname::text)-
pg_relation_size(c.relname::text)) AS Indices,
pg_size_pretty(pg_total_relation_size(c.relname::text)) AS Total
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','')
AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
AND pg_table_is_visible(c.oid)
ORDER BY c.relpages DESC limit 20;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment