Skip to content

Instantly share code, notes, and snippets.

@benjie
Created April 26, 2021 11:57
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 benjie/d56f9bef650e175b34bf3764579d379d to your computer and use it in GitHub Desktop.
Save benjie/d56f9bef650e175b34bf3764579d379d to your computer and use it in GitHub Desktop.
SELECT
pg_size_pretty(total_bytes) AS total,
pg_size_pretty(index_bytes) AS index,
pg_size_pretty(toast_bytes) AS toast,
pg_size_pretty(total_bytes - index_bytes - toast_bytes) AS table
FROM (
SELECT
pg_total_relation_size(c.oid) AS total_bytes,
pg_indexes_size(c.oid) AS index_bytes,
coalesce(pg_total_relation_size(reltoastrelid), 0) AS toast_bytes
FROM pg_class c
WHERE c.oid = 'app_public.my_table_here'::regclass
) a;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment