命中率
1)library cache的命中率:
.計算公式:library cache hit ratio = sum(pinhits) / sum(pins)
select sum(pinhits)/sum(pins) from v$librarycache;
通常在98%以上,否則,需要要考慮加大共享池,繫結變數,修改cursor_sharing等引數。
2)計算共享池記憶體使用率:
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 pool,name,bytes/1024/1024 "mb" from v$sgastat
where name = 'free memory' and pool = 'shared pool';
3)db buffer cache命中率:
計算公式:hit ratio = 1 - [physical reads/(block gets + consistent gets)]
select name, physical_reads, db_block_gets, consistent_gets,
1 - (physical_reads / (db_block_gets + consistent_gets)) "hit ratio"
from v$buffer_pool_statistics
where name='default';
通常應在90%以上,否則,需要調整,加大db_cache_size
---第二種辦法:oracle官方文件方法
命中率的計算公式為:
hit ratio = 1 - ((physical reads - physical reads direct - physical reads direct (lob)) /
(db block gets + consistent gets - physical reads direct - physical reads direct (lob))
分別代入上一查詢中的結果值,就得出了buffer cache的命中率
select name, value
from v$sysstat
where name in('session logical reads',
'physical reads',
'physical reads direct',
'physical reads direct (lob)',
'db block gets', 'consistent gets');
4)資料緩衝區命中率:
select value from v$sysstat where name ='physical reads';
select value from v$sysstat where name ='physical reads direct';
select value from v$sysstat where name ='physical reads direct (lob)';
select value from v$sysstat where name ='consistent gets';
select value from v$sysstat where name = 'db block gets';
這裡命中率的計算應該是
令 x = physical reads direct + physical reads direct (lob)
命中率 =100 - ( physical reads - x) / (consistent gets + db block gets - x)*100
通常如果發現命中率低於90%,則應該調整應用可可以考慮是否增大資料緩衝區
5)共享池的命中率:
select sum(pinhits-reloads)/sum(pins)*100 "hit radio" from v$librarycache;
假如共享池的命中率低於95%,就要考慮調整應用(通常是沒使用bind var )或者增加記憶體
6)計算在記憶體中排序的比率:
select * from v$sysstat t where name='sorts (memory)';—查詢記憶體排序數
select * from v$sysstat t where name='sorts (disk)';—查詢磁碟排序數
--caculate sort in memory ratio
select round(&sort_in_memory/(&sort_in_memory+&sort_in_disk),4)*100||'%' from dual;
此比率越大越好,太小整要考慮調整,加大pga
7)pga的命中率:
計算公式:bp x 100 / (bp + ebp)
bp: bytes processed
ebp: extra bytes read/written
select * from v$pgastat where name='cache hit percentage';
或者從oem的圖形介面中檢視
我們可以檢視乙個檢視以獲取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;
target_mb cache_hit_perc estd_overalloc_count
63 23 367
125 24 30
250 30 3
375 39 0
500 58 0
600 59 0
700 59 0
800 60 0
900 60 0
在此例中:pga至少要分配375m
我個人認為pga命中率不應該低於50%
以下的sql統計sql語句執行在三種模式的次數: optimal memory size, one-pass memory size, multi-pass memory size:
select name profile, cnt, decode(total, 0, 0, round(cnt*100/total,4)) percentage
from (select name, value cnt, (sum(value) over ()) total from v$sysstat where name like 'workarea exec%');
8)共享區字典快取區命中率
計算公式:sum(gets - getmisses - usage -fixed) / sum(gets)
命中率應大於0.85
select sum(gets-getmisses-usage-fixed)/sum(gets)
from v$rowcache;
9)資料快取記憶體區命中率
計算公式:1-(physical reads / (db block gets + consistent gets))
命中率應大於0.90最好
select name,value
from v$sysstat
where name in ('physical reads','db block gets','consistent gets');
10)共享區庫快取區命中率
計算公式:sum(pins - reloads) / sum(pins)
命中率應大於0.99
select sum(pins-reloads)/sum(pins)
from v$librarycache;
11)檢測回滾段的爭用
sum(waits)值應小於sum(gets)值的1%
select sum(gets),sum(waits),sum(waits)/sum(gets)
from v$rollstat;
12)檢測回滾段收縮次數
select name,shrinks
from v$rollstat, v$rollname
where v$rollstat.usn = v$rollname.usn;
squid 檢視命中率
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!squid檢視命中率 測試機器 用如下命令檢視squid命中率 usr local squid bin squidclient p 80 mgr info 卻提示client error cannot connect to localhost 80...
mysql索引的命中率
轉於 首先明確 為什麼要用聯合索引?對於查詢語句 select e.from e where e.e1 1 and e.e3 2 涉及到兩列,這個時候我們一般採用乙個聯合索引 e1,e3 而不用兩個單列索引,這是因為一條查詢語句往往應為mysql優化器的關係只用乙個索引,就算你有兩個索引,他也只用乙...
Squid服務中的快取命中率
談談squid服務中的快取命中率 cache命中在squid每次從它的快取裡滿足http請求時發生。cache命中率,是所有http請求中命中的比例。web快取典型的cache命中率在30 到60 之間。另乙個相似的度量單位叫做位元組命中率,描繪了cache提供服務的資料容量 位元組數 cache丟...