Useful PostgreSQL Queries
From Observer GigaFlow Support | VIAVI Solutions Inc.
Revision as of 08:44, 13 September 2017 by Kevin Wilkie (Talk | contribs)
Finding the largest tables
SELECT nspname || '.' || relname AS "relation", pg_size_pretty(pg_relation_size(C.oid)) AS "size" FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) WHERE nspname NOT IN ('pg_catalog', 'information_schema') ORDER BY pg_relation_size(C.oid) DESC LIMIT 20;