日期:2014-05-16  浏览次数:20445 次

Oracle 11g 中 Direct path reads 特性 说明

 

一.DirectPath Reads 说明

在oracle 11g以前的版本中,如果对大表进行全表扫描,wait event是:db file scattered read;在11g中,如果对大表进行全表扫描,wait event是:direct path read;即在11g中,大表全表扫描是将数据块直接读入会话的pga区域。(具体的查看方法参考后面的示例)。

            在11g中,大表全表扫描时数据块不经过sga而直接进pga,这样会造成每次进行大表全表扫描,物理读都是很大,而在10g中,由于全表扫描的数据块在sga中已经存在,所以执行全表扫描时,它的物理读为0。

            但是这里主要是oracle在优化策略上的进步,即假定大表频繁全表扫描这种现象,在生产库上不会太多,通过把数据直接读入pga,进而减少了cachebuffer的繁忙交换程度,提高了cachebuffer的使用效率.

 

direct path read具备更多的优势:

1. 减少了对栓的使用,避免可能的栓争用

2. 物理IO的大小不再取决于buffer_cache中所存在的块;试想某个8个块的extent中1,3,5,7号块在高速缓存中,而2,4,6,8块没有被缓存,传统的方式在读取该extent时将会是对2,4,6,8块进行4次db file sequential read,这是一种十分可怕的状况,其效率往往要比单次读取这个区间的所有8个块还要低得多,虽然Oracle为了避免这种情况总是尽可能的不缓存大表的块(读入后总是放在队列最冷的一端);而direct path read则可以完全避免这类问题,尽可能地单次读入更多的物理块。

 

direct path read也会引入一些缺点:

1.在直接路径读取某段前需要对该对象进行一次段级的检查点(A segmentcheckpoint).

2.可能导致重复的延迟块清除操作.

 

该部分引用Maclean 的Blog:

直接路径读取对于延迟块清除的影响

http://www.oracledatabase12g.com/archives/direct-read-impact-on-delayed-block-read.html

 

 

MOS 上的说明:High 'direct path read' waits in 11g [ID 793845.1]

There have beenchanges in 11g in the heuristics to choose between direct path reads or readsthrough buffer cache for serial table scans. 

In 10g, serialtable scans for "large" tables used to go through cache (by default)which is not the case anymore.  In 11g, this decision to read viadirect path or through cache is based on the size of the table, buffer cachesize and various other stats. 

Direct path reads are faster than scattered reads andhave less impact on other processes because they avoid latches.

 

 

二.相关等待事件说明

 

Oracle 常见的33个等待事件

http://blog.csdn.net/tianlesoftware/article/details/5807800

 

2.1 查看等待事件分类情况:

/* Formatted on 2010/8/11 16:08:55 (QP5v5.115.810.9015) */

  SELECT   wait_class#,

           wait_class_id,

           wait_class,

           COUNT ( * ) AS "count"

    FROM   v$event_name

GROUP BY   wait_class#, wait_class_id, wait_class

ORDER BY   wait_class#;

 

WAIT_CLASS# WAIT_CLASS_IDWAIT_CLASS                count

----------- ------------- ------------------------------

          0    1893977003Other                       717

          1    4217450380Application                  17

          2    3290255840Configuration