Oracle性能调优过程中如何观察缓存命中率

4/29/2008来源:Oracle教程人气:4405

Oracle数据库性能调优的过程中,当需要观察缓存命中率(Measure the Buffer Cache Hit Ratio)时,我们可以使用下面的语句:

rem-------------------------------------------
rem 测量缓存命中率
rem ------------------------------------------

-- 获取初始缓存命中率...
SELECT ROUND((1-(phy.value / (cur.value + con.value)))*100,2) "Cache Hit Ratio"
FROM v$sysstat cur, v$sysstat con, v$sysstat phy
WHERE cur.name = 'db block gets'
AND con.name = 'consistent gets'
AND phy.name = 'physical reads'
/

-- 我们人为来增加缓存命中率...
DECLARE
v_dummy dual.dummy%TYPE;
BEGIN
FOR I IN 1..1000 LOOP
SELECT dummy INTO v_dummy FROM dual;
END LOOP;
END;
/

-- 我们再来测量...
SELECT ROUND((1-(phy.value / (cur.value + con.value)))*100,2) "Cache Hit Ratio"
FROM v$sysstat cur, v$sysstat con, v$sysstat phy
WHERE cur.name = 'db block gets'
AND con.name = 'consistent gets'
AND phy.name = 'physical reads'
/