Last active
February 8, 2021 02:50
-
-
Save StevenJL/da51473bd5edda326245367310896f21 to your computer and use it in GitHub Desktop.
PSQL index cache hit ratio
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
# See Cache Hit Ratio for a given index | |
SELECT | |
(heap_blks_hit::decimal / (heap_blks_hit + heap_blks_read)) as cache_hit_ratio | |
FROM | |
pg_statio_user_indexes | |
WHERE indexrelname = 'some_high_use_index'; | |
# See overall Cache Hit Ratio across all indexes | |
SELECT | |
sum(idx_blks_hit)/(sum(idx_blks_read) + sum(idx_blks_hit)) as cache_hit_ratio | |
FROM | |
pg_statio_user_indexes; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment