Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. // This will report size information for all tables, in both raw bytes and "pretty" form.
  2. SELECT *, pg_size_pretty(total_bytes) AS total
  3. , pg_size_pretty(index_bytes) AS INDEX
  4. , pg_size_pretty(toast_bytes) AS toast
  5. , pg_size_pretty(table_bytes) AS TABLE
  6. FROM (
  7. SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM (
  8. SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME
  9. , c.reltuples AS row_estimate
  10. , pg_total_relation_size(c.oid) AS total_bytes
  11. , pg_indexes_size(c.oid) AS index_bytes
  12. , pg_total_relation_size(reltoastrelid) AS toast_bytes
  13. FROM pg_class c
  14. LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
  15. WHERE relkind = 'r'
  16. ) a
  17. ) a;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement