千家信息网

Oracle direct path read相关隐含参数

发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,In 10g, serial table scans for "large" tables go through the buffer cache (by default).Oracle 10G,默认
千家信息网最后更新 2026年11月02日Oracle direct path read相关隐含参数In 10g, serial table scans for "large" tables go through the buffer cache (by default).

Oracle 10G,默认时,即使对表全表扫描也会先缓存到buffer cache中,parallel方式除外

In 11g or higher, there has a been a change in the rules that choose between using 'direct path reads' and reads through the buffer cache for serial (i.e. non-parallel) table scans. This decision is based on the size of the table, buffer cache size, and various other statistics. Since Direct path reads are faster than scattered reads and have less impact on other processes because they avoid latches, it is likely that they will be chosen for such reads in 11g and above.

Oracle 11G及之后版本,发生了变化,全表扫描可通过直接路径读(Direct Path Read)绕开buffer cache方式来执行,是否Direct Path Read取决于table大小,buffer cache大小,其它统计信息。

由于Direct Path Read比scattered reads快,并且由于避免latch而对其他进程的影响较小,因此11G之后很可能使用Direct Path Read

Oracle direct path read相关参数

_serial_direct_read

是否启用11G direct path read限制,其默认值为AUTO启用,设置为NEVER时禁用自动direct path read的特性。该参数可以动态在实例或会话级别修改,而无需重启实例。

select nam.ksppinm NAME,val.KSPPSTVL VALUE from x$ksppi nam, x$ksppsv val where nam.indx = val.indx and nam.ksppinm = '_serial_direct_read';alter system set "_serial_direct_read"=auto;alter system set "_serial_direct_read"=never;

_small_table_threshold

默认值为buffer cache的2%, 单位:块

就是说 table的blocks数大于_small_table_threshold这个值Oracle就认为是大表,就会走 direct path read

select nam.ksppinm NAME,val.KSPPSTVL VALUE from x$ksppi nam, x$ksppsv val where nam.indx = val.indx and nam.ksppinm = '_small_table_threshold';

_direct_read_decision_statistics_driven

11.2.0.2之后出现,默认值为TRUE

select nam.ksppinm NAME,val.KSPPSTVL VALUE from x$ksppi nam, x$ksppsv val where nam.indx = val.indx and nam.ksppinm = '_direct_read_decision_statistics_driven';

When the above parameter is FALSE, the direct path read decision is done based on the actual block count of segment header.
When the above parameter is TRUE (default from 11.2.0.2), the direct path read decision is done based on the optimizer statistics.

TRUE: 代表走direct path read的判定,基于table的统计信息。

比如:

(1) SQL> SELECT blocks FROM user_tables WHERE table_name = 'TABLE_NAME';
Example:
If the blocks from user_tables for the object show 100 and _small_table_threshold is set to 480 then set the blocks statistics manually to 1000 so that it would go for direct path read.

(2) Set the no.of blocks statistics for the tables involved in the SQL manually greater than the "_small_table_threshold" value.
SQL> EXEC DBMS_STATS.SET_TABLE_STATS('username','tabname',numblks=>n);
Example:
SQL> EXEC DBMS_STATS.SET_TABLE_STATS(user,'TEST',numblks=>1000);

统计信息查询TABLE有100个block小于_small_table_threshold 480话,就不会走direct path read。如果统计信息block设置超过480话就会走direct path read

FLASE: 代表走direct path read的判定,基于table segment header实际的block数

10949 事件

通过设置10949事件屏蔽direct path read特性,返回到Oracle 10G及之前的模式:
alter session set events '10949 trace name context forever, level 1';

还有一个参数 _very_large_object_threshold 用于设定(MB单位)使用DPR( direct path read)方式的上限,这个参数需要结合10949事件共同发挥作用。
10949 事件设置任何一个级别都将禁用DPR的方式,但是仅限于小于 5 倍 BUFFER Cache的数据表,同时,如果一个表的大小大于 0.8 倍的 _very_large_object_threshold 设置,也会执行DPR。


这些限定的目标在于:
对于大表的全表扫描,必须通过Direct Path Read方式执行,以减少对于Buffer Cache的冲击和性能影响。
但是我们可以通过参数调整来决定执行DPR的上限和下限。

Event 10949 可以在线设置,但对现有session可能不会生效,新登录的会话会执行新的设置:

在实例级别修改参数设置:

ALTER SYSTEM SET EVENTS '10949 TRACE NAME CONTEXT FOREVER';

增加参数到SPFILE中:

alter system set event='10949 TRACE NAME CONTEXT FOREVER' scope=spfile;

对当前会话设置:

ALTER SESSION SET EVENTS '10949 TRACE NAME CONTEXT FOREVER';

参考:

https://www.eygle.com/archives/2012/05/oracle_11g_direct_path_read.html

http://www.savedba.com/?p=619

How To Force Direct Path Read for SQL Statements (Doc ID 2426051.1)

参数 方式 事件 信息 统计 大小 实例 级别 上限 代表 单位 特性 影响 下限 作用 动态 取决于 可以通过 同时 实际 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 江苏根荣互联网科技 善班互联网科技 礼当家互联网科技 北京互联网络科技有限公司 唐信互联网科技 大连 左右互联网络科技 深圳前海聚择互联网科技有限公司 新华互联网科技2019 佳云科技和互联网广告 互联网科技与管理 速维有品互联网信息科技(苏州)有限公司 每天都有哪些好的互联网科技 上海钢联属于互联网科技股吗 互联网风格科技公司名称 2021世界互联网领先科技成果发布 上海乐五互联网科技有限公司 安徽零酒互联网科技有限公司 青岛易易互联网科技 山东蛋芒互联网科技有限公司 杭州科技互联网公司有哪些 互联网科技公司华为 智网互联网科技 南山科技园互联网公司有哪些 互联网金融中的现代科技 互联网科技和法律行业 互联网方面的科技前沿 高科技互联网套路 产业互联网科技服务公司 扫呗互联网科技有限公司 华人运通互联网科技公司
0