Last active
June 26, 2017 19:43
-
-
Save michelmilezzi/b52854c920c17b220ba328c7a98cb9e5 to your computer and use it in GitHub Desktop.
PostgreSQL query that calculates overall status of indexes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
COUNT(*) FILTER (WHERE idx_scan = 0) AS no_hit, | |
COUNT(*) FILTER (WHERE idx_scan > 0) AS used, | |
COUNT(*) AS total | |
FROM | |
pg_stat_user_indexes s | |
JOIN pg_index i ON (i.indexrelid = s.indexrelid) | |
WHERE | |
NOT i.indisprimary; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment