如何计算几个命中率
LC的命中率:
计算公式:Library Cache Hit Ratio = sum(pinhits) / sum(pins)
SELECT SUM(pinhits)/sum(pins) FROM V$LIBRARYCACHE
通常在98%以上,否则,需要要考虑加大共享池,绑定变量,修改cursor_sharing等参数。
计算共享池内存使用率:
SELECT(1- ROUND(BYTES /(&TSP_IN_M *1024*1024),2))*100|| '%'
FROM V$SGASTAT
WHERE NAME= 'free memory'
AND POOL = 'shared pool';
其中: &TSP_IN_M是你的总的共享池的SIZE(M)
共享池内存使用率,应该稳定在75%-90%间,太小浪费内存,太大则内存不足。
查询空闲的共享池内存:
SELECT * FROM V$SGASTAT WHERE NAME= 'free memory' AND POOL = 'shared pool';
PGA的命中率:
计算公式:BP x 100 / (BP + EBP)
BP: bytes processed EBP: extrabytesread/written
SELECT * FROM V$PGASTAT WHERE NAME='cache hit percentage';
我们可以查看一个视图以获取Oracle的建议值:
SELECT round(PGA_TARGET_FOR_ESTIMATE/1024/1024) target_mb,
ESTD_PGA_CACHE_HIT_PERCENTAGE cache_hit_perc,
ESTD_OVERALLOC_COUNT
FROM V$PGA_TARGET_ADVICE;
运行以下查询以确定自数据库启动以来分配的最大实例PGA:单位M
SQL> select value from v$pgastat where name='maximum PGA allocated';
memory_target = sga_target + max(pga_aggregate_target, maximum PGA allocated)
run the following query in the database to obtain a value for SGA_TARGET:
SELECT (
(SELECT SUM(value) FROM V$SGA) -
(SELECT CURRENT_SIZE FROM V$SGA_DYNAMIC_FREE_MEMORY)
) "SGA_TARGET"
FROM DUAL;