Skip to content

Instantly share code, notes, and snippets.

@jdvor
Created March 12, 2019 19:15
Show Gist options
  • Save jdvor/3fc4c613ab505df953b8d18b8eb13cca to your computer and use it in GitHub Desktop.
Save jdvor/3fc4c613ab505df953b8d18b8eb13cca to your computer and use it in GitHub Desktop.
Get list of big objects (tables, indexes) in PostgreSQL database. The list is sorted by size descending.
SELECT
relname AS objectname,
relkind AS objecttype,
reltuples AS "#entries", pg_size_pretty(relpages::bigint*8*1024) AS size
FROM pg_class
WHERE relpages >= 8
ORDER BY relpages DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment