Skip to content

Instantly share code, notes, and snippets.

@mrchrisadams
Created June 8, 2018 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrchrisadams/531fc7440fc0a27343366d0d19da033d to your computer and use it in GitHub Desktop.
Save mrchrisadams/531fc7440fc0a27343366d0d19da033d to your computer and use it in GitHub Desktop.
How big are all the tables in the 'public' schema in postgres
WITH disk_tables AS
(SELECT nspname,
relname,
pg_relation_size(c.oid) AS "size"
FROM pg_class c
LEFT JOIN pg_namespace n ON (n.oid = c.relnamespace)
WHERE nspname IN ('public'))
SELECT pg_size_pretty(SUM(disk_tables.size)) FROM disk_tables;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment