Created
May 7, 2012 00:43
-
-
Save mattsoldo/2625185 to your computer and use it in GitHub Desktop.
PostgreSQL Index hit percentage by table
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 | |
schemaname::text, | |
relname::text, | |
seq_tup_read, | |
idx_tup_fetch, | |
seq_tup_read + idx_tup_fetch as total_reads, | |
round(100 * idx_tup_fetch / (seq_tup_read + idx_tup_fetch)) as idx_read_pct, | |
pg_size_pretty(pg_total_relation_size(relid)) as total_size | |
FROM | |
pg_stat_user_tables | |
JOIN | |
pg_stat_database ON datname = current_database() | |
WHERE | |
(seq_tup_read + idx_tup_fetch > 0) AND | |
tup_returned > 0 | |
ORDER BY | |
(seq_tup_read + idx_tup_fetch) desc -- A.K.A. "total_reads" | |
limit | |
50; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment