|
一般在OLAP环境中,大表在进行全表扫描的时候一般会出现direct path read等待事件,如果在OLTP环境中,出现大量的direct path read直接路径读取,这样就有问题了。一般在OLTP中,都是事物型的sql,如果想sql执行效率,那么最好从内存当中读取数据,直接从数据文件中读取,后果可想而知了。这里就可能需要我们禁用direct path read。
一个隐含参数:
_serial_direct_read = false 禁用direct path read
_serial_direct_read = true 启用direct path read
alter system set "_serial_direct_read"=never scope=both sid='*'; 可以显着减少direct path read
测试如下:
[oracle@localhost ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Apr 24 14:55:32 2019
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> SELECT x.ksppinm NAME, y.ksppstvl VALUE, x.ksppdesc describ
2 FROM SYS.x$ksppi x, SYS.x$ksppcv y
3 where x.indx = y.indx
4 AND (x.ksppinm ='_small_table_threshold' or x.ksppinm='_serial_direct_read');
NAME VALUE DESCRIB
---------------------------------------- -------------------- -------------------------------------------------------
_small_table_threshold 1023 lower threshold level of table size for direct reads
_serial_direct_read AUTO enable direct read in serial
可以看到默认_serial_direct_read参数为auto,那么在oracle中,什么样的表会被断定为大表?
可以看到_small_table_threshold隐含参数,其value为1023,单位是block,默认值是db cache size的2%大小,这个是在实例启动的时候动态决定的。在11gr2之后,当一个表的块数大于_small_table_threshold的时候,就被判定为大表,否则就视为小表。对于大表,在进行全表扫描的时候,oracle会根据_serial_direct_read的值来确定是否执行direct path read,如果值为auto,那就会direct path read。
在线修改_serial_direct_read是动态参数
SQL> alter system set "_serial_direct_read"=never scope=both sid='*';
System altered.
验证:
SQL> r
1 SELECT x.ksppinm NAME, y.ksppstvl VALUE, x.ksppdesc describ
2 FROM SYS.x$ksppi x, SYS.x$ksppcv y
3 where x.indx = y.indx
4* AND (x.ksppinm ='_small_table_threshold' or x.ksppinm='_serial_direct_read')
NAME VALUE DESCRIB
---------------------------------------- -------------------- -------------------------------------------------------
_small_table_threshold 1023 lower threshold level of table size for direct reads
_serial_direct_read NEVER enable direct read in serial
SQL>
|
|