Created
June 22, 2015 13:11
-
-
Save rkmax/5e0f2536a7b3e4d7433d to your computer and use it in GitHub Desktop.
Show if you are using your indexes on postgres databases
This file contains 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 | |
relname, | |
seq_scan - idx_scan AS too_much_seq, | |
CASE WHEN seq_scan - idx_scan > 0 | |
THEN 'Missing Index?' | |
ELSE 'OK' END, | |
pg_relation_size(relname :: REGCLASS) AS rel_size, | |
seq_scan, | |
idx_scan | |
FROM pg_stat_all_tables | |
WHERE schemaname = 'public' AND pg_relation_size(relname :: REGCLASS) > 80000 | |
ORDER BY too_much_seq DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment