Skip to content

Instantly share code, notes, and snippets.

@mauricio
Created September 15, 2012 21:32
Show Gist options
  • Select an option

  • Save mauricio/3729884 to your computer and use it in GitHub Desktop.

Select an option

Save mauricio/3729884 to your computer and use it in GitHub Desktop.
SELECT
nspname,relname,relkind,
round(100 * pg_relation_size(indexrelid) / pg_relation_size(indrelid)) / 100
AS index_ratio,
pg_size_pretty(pg_relation_size(indexrelid)) AS index_size,
pg_size_pretty(pg_relation_size(indrelid)) AS table_size
FROM pg_index I
LEFT JOIN pg_class C ON (C.oid = I.indexrelid)
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE
relname IN ('accounts_pkey') AND
pg_relation_size(indrelid) > 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment