latch free 中 cache buffer chain 的整理
- 在data buffer中,所有的塊都在一個hash table 的 link list 中。每一個 hash chain 都由一個single child latch 保護著。一個latch必須要得到該latch 才能夠掃描該 hash chain 以保證該hash chain 上的blocks 不被修改
- 引發 cache buffer chain latch 的競爭的原因大概由如下原因:
1. buffer chain 太長了: 太長的意義是指:lots of blocks all hashing to the same list (eg: having hundreds of consistent
read versions of the same block and having hundreds of blocks on a list can add up) 增加 DB_BLOCK_LRU_LATCHES 引數
2. 有havey access to the same block : 調整SQL - 如果我們執行以下查詢:select count(*) from v$latch_children where name = 'cache buffers chains'; 我們就能夠得到當前我們buffer cache中存在 hash chain 的個數。 這個數字要根據buffer cache 的大小而定,buffer越大,hash chain就越多,hash chain越多,關於這個latch 的競爭就越少
- db_block_lru_latches and cache buffers chains are different beasts. db_block_lru_latches is normally used in conjunction with multiple buffer pools or multiple dbwr's. cache buffers chains are latches to the individual, hashed lists of buffered blocks. they are separate. db_block_lru_latches 一般用在多個buffer pools 或者 多個DBWR 程式間的;
在8i中,該值的預設值為CPU的一半,在9i中已經預設為CPU的2倍了,如果這個值過於小,就會發生該等待事件
主要診斷辦法:
- 執行如下sql,檢視有多少session 正在處在cache buffer chain 等待:
select a.sid,a.SEQ#,a.SECONDS_IN_WAIT,b.NAME,b.GETS,b.MISSES,b.SLEEPS
from v$session_wait a ,v$latch b
where a.EVENT='latch free' and a.p2=b.LATCH# - 執行如下sql,確定sleeps 次數最多的 session
select CHILD# "cCHILD"
, ADDR "sADDR"
, GETS "sGETS"
, MISSES "sMISSES"
, SLEEPS "sSLEEPS"
from v$latch_children
where name = 'cache buffers chains'
order by 5, 1, 2, 3; - 執行如下sql,得到引發 cache buffers chains 等待得熱塊:
SELECT owner, segment_name,a.segment_type,a.file_id,b.dbablk,
decode(b.state, 0, 'FREE', /* not currently is use */
1, 'XCUR', /* held exclusive by this instance */
2, 'SCUR', /* held shared by this instance */
3, 'CR', /* only valid for consistent read */
4, 'READ', /* is being read from disk */
5, 'MREC', /* in media recovery mode */
6, 'IREC') state,/* in instance(crash) recovery mode */
decode (b.flag, 1, 'buffer dirty' ,
2, 'about to modify; try not to start io' ,
4, 'modification started, no new writes',
8, 'block logged' ,
16, 'temporary data - no redo for changes',
32, 'being written; cant modify',
64, 'waiting for write to finish',
128, 'checkpoint asap',
256, 'recovery reading, do not reuse, being read',
512, 'unlink from lock element - make non-current',
1024, 'write block & stop using for lock down grade',
2048, 'write block for cross instance call',
4096, 'reading from disk into KCBBHCR buffer',
8192, 'has been gotten in current mode',
16384, 'stale - unused CR buf made from current',
32768, 'Direct Access to buffer contents',
131072, 'Hash chain Dump used in debug print routine',
524288, 'sequential scan only flag',
1048576, 'Set to indicate a buffer that is NEW',
2097152, 're-write if being written (sort)',
4194304, 'buffer is "logically" flushed',flag) flag
FROM DBA_EXTENTS a , x$bh b
WHERE a.file_id = b.file# and b.hladdr in ('C000000005EB8468', 'C000000005F3A8C8', 'C000000005D0C148')
AND b.dbablk between a.block_id AND a.block_id + a.blocks - 1;
其中,括號中得地址為第二步產生得sAddr。這個是8i中的sql,從817開始,已經有了TCH一列,可以作為最熱塊的標記 - 檢視第三步生產的結果
If, you see unique block#s, then contention is at the hash bucket's chain level (a). If the same block# appears, then the block is receiving high-traffic (b).
if a) --> increase _db_block_hash_buckets (i put it on 4096)
else if b) --> increase freelists/initrans, etc (depending on the type of lock , insert, update, etc). Locally managed Tablespaces. View querys, etc - High waits on the cache buffers chains latch can happen if your db_block_lru_latches setting is too low. The default value is CPU_COUNT/2 in Oracle8i, but a good value to try is CPU_COUNT * 2. The db_block_lru_latches parameter is hidden in Oracle9i and defaults to _CPU_COUNT * 2.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7916042/viewspace-915053/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- latch free(cache buffers chain)AI
- Cache Buffer Chain Latch等待事件AI事件
- cr塊和latch buffer cache chainAI
- cache buffer chain latch只讀共享?AI
- cache buffer lru chain latch等待事件AI事件
- buffer cache實驗5-latch:cache buffers chainAI
- cache buffer chain latch可以以只讀模式共享AI模式
- cache buffer chainAI
- cache buffers LRU chain latchAI
- oracle實驗記錄(buffer_cache分析(3)cbc lru chain latch)OracleAI
- Latch: cache buffer chains (%)AI
- 等待模擬-cache buffer chainAI
- latch free事件的整理事件
- 等待事件_cache_buffers_lru_chain_latch事件AI
- latch free事件的整理(轉)事件
- cbc latch或cache buffer chains latch系列一AI
- 【BUFFER】Oracle buffer cache之 latch 學習記錄Oracle
- Linux free中buffer與cache區別Linux
- 由最長SQL想到的Latch Free( Library Cache Pin/Lock)整理~~草稿SQL
- buffer cache與相關的latch等待事件事件
- buffer cache實驗6-latch:cache buffers lru chainsAI
- buffer cache實驗8-free buffer waits-完成AI
- 12c設定RESULT_CACHE_MODE=MANUAL發生'Result Cache:RC Latch'型別的Latch Free等待型別
- oracle實驗記錄 (buffer_cache分析(2)cbc latch)Oracle
- 客戶資料庫出現大量cache buffer chains latch資料庫AI
- High Water Mark過高導致cache buffer chain等待嚴重AI
- cache buffers lru chainAI
- 關於cache_buffer_lru_chain的疑問,知道的給小弟解答一下。AI
- buffer busy waits, latch cache buffers chains, read by other session區別AISession
- latch free等待事件事件
- linux系統中的Cache和BufferLinux
- page cache與buffer cache的關係
- Buffer Cache 原理
- cache buffers chains vs cache buffers lru chainAI
- Oracle中flush buffer cache和x$bhOracle
- 記憶體中,cache與buffer的含義記憶體
- Linux下的快取機制free及清理buffer/cache/swap的方法梳理Linux快取
- Latch free等待事件(轉)事件