Postgresql: table size

1
2
3
4
5
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;