Query to obtain Cache Hit Ratio on IBM DB2

The cache hit ratio is one of the indicators used for tuning tasks. It Measures the percentage of hits in memory, specifically in the bufferpools (each of them).

To get the cache hit ratio for each buffer pool configured to run this query:

SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME, SUBSTR(BP_NAME,1,14) AS BP_NAME,
TOTAL_HIT_RATIO_PERCENT, DATA_HIT_RATIO_PERCENT,
INDEX_HIT_RATIO_PERCENT
FROM SYSIBMADM.BP_HITRATIO ORDER BY DBPARTITIONNUM

 

This query shows the ratio for each cache buffer, separating between the ratio obtained with data blocks and index blocks.

If the value of this ratio is above 90%, it’s ok, if not: may indicate a problem with the memory size assigned to the instance.