Skip to content

Instantly share code, notes, and snippets.

@parasquid
Created January 8, 2017 03:03
Show Gist options
  • Save parasquid/769758276891e00c4798e76c0e118a27 to your computer and use it in GitHub Desktop.
Save parasquid/769758276891e00c4798e76c0e118a27 to your computer and use it in GitHub Desktop.
Find out which records are taking up space
SELECT
relname as "Table",
pg_size_pretty(pg_total_relation_size(relid)) As "Size",
pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) as "External Size"
FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC;
SELECT schemaname,relname,n_live_tup
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC;
https://wiki.postgresql.org/wiki/Disk_Usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment