Skip to content

Instantly share code, notes, and snippets.

@vncsna
Created January 10, 2024 13:58
Show Gist options
  • Save vncsna/45b8767ecafb460c3ee5226bbf151a4b to your computer and use it in GitHub Desktop.
Save vncsna/45b8767ecafb460c3ee5226bbf151a4b to your computer and use it in GitHub Desktop.
PostgreSQL Size of Indexes
-- Reference
-- https://stackoverflow.com/questions/46470030/postgresql-index-size-and-value-number
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='uploads'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment