db file sequential read及優化

wzq609發表於2014-06-17

db file sequential read:直接路徑讀;

 

官方說明如下:

This event signifies that the user process is reading a buffer into the SGA buffer cache and is waiting for a physical I/O call to return. A sequential read is a single-block read.

Single block I/Os are usually the result of using indexes. Rarely, full table scan calls could get truncated to a single block call because of extent boundaries, or buffers present in the buffer cache. These waits would also show up as db file sequential read.

Check the following V$SESSION_WAIT parameter columns:

?P1: The absolute file number

?P2: The block being read

?P3: The number of blocks (should be 1)

 

解釋:ORACLE程式需要訪問block不能從SGA中獲取的時候,因此oracle程式會等待block從I/O讀取到SGA;

一個順序讀是一個單塊讀,單塊I/O一般來自索引讀的結果;

db file sequential read等待事件有3個引數:

?P1: The absolute file number             檔案號

?P2: The block being read                first block#     

?P3: The number of blocks (should be 1)       block數量

db file sequential read等待時間是由於執行對索引,回滾(undo)段,和表(當藉助rowid來訪問),控制檔案和資料檔案頭的單塊讀操作SQL語句(使用者和遞迴)引起的。對於這些物件的物理I/O請求是很正常的,因此db file sequential read等待的存在不是一定意味庫或應用出錯了。如果會話在這事件上花了好長事件,它可能也不是一個糟糕的事情。相反,如果會話花了大量時間在equeue或latch free上,那麼一定是有問題。

 

問題:AWR報告中的系統的等待事件中的db file sequential read是否合理?

根據awr報告中的以下重要引數進行解讀,以11G的awr報告為例子:

說明:db file sequential read是指sga中找不到相應的資料,所以跟buffer hit有很大的關係,當buffer hit命中率太低了,相應的db file sequential read就會高,一般buffer hit保持著95%以上;

 

檢視這個報告的db file sequential read的總時間和平均時間;

 

Foreground Wait Events也會統計db file sequential read所花費的時間和平均時間

 

根據SQL User I/O等待時間,檢視是否有調優的空間;

 

db file sequential read的優化方法:

  1. 從讀取開始,增加SGA中buffer cache的大小,避免每次都從硬碟中去讀數;
  2. 優化sql語句,減少不必要的塊讀取;

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

本文作者:JOHN

ORACLE技術部落格:ORACLE 獵人筆記               資料庫技術群:367875324 (請備註ORACLE管理 )  

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12679300/viewspace-1185623/,如需轉載,請註明出處,否則將追究法律責任。

相關文章