Skip to content

Instantly share code, notes, and snippets.

@Charmatzis
Created November 14, 2023 06:45
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 Charmatzis/bac546af24cf6c62f197d9f73e0cb5f4 to your computer and use it in GitHub Desktop.
Save Charmatzis/bac546af24cf6c62f197d9f73e0cb5f4 to your computer and use it in GitHub Desktop.
Get index size (Postgres)
SELECT i.relname "Table Name",indexrelname "Index Name",
pg_size_pretty(pg_total_relation_size(relid)) As "Total Size",
pg_size_pretty(pg_indexes_size(relid)) as "Total Size of all Indexes",
pg_size_pretty(pg_relation_size(relid)) as "Table Size",
pg_size_pretty(pg_relation_size(indexrelid)) "Index Size",
reltuples::bigint "Estimated table row count"
FROM pg_stat_all_indexes i JOIN pg_class c ON i.relid=c.oid
WHERE i.relname='table_name';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment