搜索
您的当前位置:首页Oracle数据库关于命中率的查询语句总结

Oracle数据库关于命中率的查询语句总结

时间:2020-11-09 来源:乌哈旅游

1) Library Cache的命中率公式:Library Cache Hit Ratio=SUM(PINHITS)/SUM(PINS)SELECT SUM(PINHITS)/SUM(PINS) FROM V$LIBRAR

1) Library Cache的命中率
公式:Library Cache Hit Ratio=SUM(PINHITS)/SUM(PINS)
SELECT SUM(PINHITS)/SUM(PINS) FROM V$LIBRARYCACHE;

命中率不能低于99%,,否则需要考虑是否受共享池大小,绑定变量,cursor_sharing等因素的影响。
SELECT NAME,VALUE FROM V$PARAMETER WHERE

2) Shared Pool的使用率
公式:Shared Pool Hit Ratio=(100-Free memory/shared_pool_size*100)%
如果数据库采用AMM方式管理内存使用以下语句获取Shared Pool大小:

SELECT POOL,ROUND(SUM(BYTES)/1024/1024,2) FROM V$SGASTAT where POOL='shared pool' group by POOL;

如果是采取Manual方式管理内存则:
SELECT NAME,VALUE FROM V$PARAMETER WHERE;

查询1:

SELECT 100 - ROUND((SELECT ROUND(SUM(BYTES) / 1024 / 1024, 2) BYTES
FROM V$SGASTAT
WHERE NAME = 'free memory'
AND POOL = 'shared pool'
GROUP BY POOL) / ROUND(SUM(BYTES) / 1024 / 1024, 2),
4) * 100 || '%' RATIOS
FROM V$SGASTAT
where POOL = 'shared pool'
GROUP BY POOL

查询2:
SELECT 100 - ROUND(B.BYTES / ROUND(SUM(A.BYTES) / 1024 / 1024, 2),4)*100 || '%' RATIOS
FROM V$SGASTAT A,
(SELECT POOL,ROUND(SUM(BYTES) / 1024 / 1024, 2) BYTES
FROM V$SGASTAT
WHERE NAME = 'free memory' AND POOL='shared pool' GROUP BY POOL) B
where A.POOL = 'shared pool' GROUP BY B.BYTES,A.POOL

共享池使用率应稳定在75%-90%间,过小则浪费,过大说明内存不足或语句重用性不高。

本文永久更新链接地址:

Top