Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. SELECT *, pg_size_pretty(total_bytes) AS total
  2. , pg_size_pretty(index_bytes) AS INDEX
  3. , pg_size_pretty(toast_bytes) AS toast
  4. , pg_size_pretty(table_bytes) AS TABLE
  5. FROM (
  6. SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM (
  7. SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME
  8. , c.reltuples AS row_estimate
  9. , pg_total_relation_size(c.oid) AS total_bytes
  10. , pg_indexes_size(c.oid) AS index_bytes
  11. , pg_total_relation_size(reltoastrelid) AS toast_bytes
  12. FROM pg_class c
  13. LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
  14. WHERE relkind = 'r'
  15. ) a
  16. ) a
  17. WHERE table_schema NOT IN ('pg_catalog', 'information_schema')
  18. ORDER BY total_bytes desc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement