Posted By

kmorey on 02/05/11


Tagged


Versions (?)

Find largest tables in Postgres


 / Published in: SQL
 

  1. SELECT nspname || '.' || relname AS "relation",
  2. pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"
  3. FROM pg_class C
  4. LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
  5. WHERE nspname NOT IN ('pg_catalog', 'information_schema')
  6. AND C.relkind <> 'i'
  7. AND nspname !~ '^pg_toast'
  8. ORDER BY pg_total_relation_size(C.oid) DESC
  9. LIMIT 20;

Report this snippet  

You need to login to post a comment.