Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 15:54:02
Original
1145 people have browsed it

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%间,过小则浪费,过大说明内存不足或语句重用性不高。

本文永久更新链接地址

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template