分类: Oracle
2009-10-26 16:34:39
转自:
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'
/
(the end)