Skip to content

Instantly share code, notes, and snippets.

@jfrost
Created September 16, 2013 18:53
Show Gist options
  • Save jfrost/6584871 to your computer and use it in GitHub Desktop.
Save jfrost/6584871 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