Skip to content

Instantly share code, notes, and snippets.

@kenvac
Forked from jfrost/gist:6584871
Created July 10, 2018 14:55
Show Gist options
  • Save kenvac/a84b88337cc147fe12c07cb30462b288 to your computer and use it in GitHub Desktop.
Save kenvac/a84b88337cc147fe12c07cb30462b288 to your computer and use it in GitHub Desktop.
PostgreSQL query: completely unused indexes
-- Completely unused indexes:
SELECT relid::regclass as table, indexrelid::regclass as index
, pg_size_pretty(pg_relation_size(indexrelid))
FROM pg_stat_user_indexes
JOIN pg_index
USING (indexrelid)
WHERE idx_scan = 0
AND indisunique IS FALSE order by pg_relation_size(indexrelid);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment