[20171120]11G关闭直接路径读.txt
[20171120]11G关闭直接路径读.txt
--//今天做filesystemio_options参数测试时,遇到一个关于直接路径读的问题.
--//如果看以前的博客介绍,设置"_serial_direct_read"=never或者events '10949 trace name context forever';就可以关闭直接路径读.
--//我的测试在11GR2下set events '10949 trace name context forever';不行.
--//通过例子来说明问题
1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
SCOTT@book> create table t as select rownum id from dual connect by level<=2;
Table created.
SCOTT@book> ALTER TABLE t MINIMIZE RECORDS_PER_BLOCK ;
Table altered.
--//这样可以实现每块2条记录.
SCOTT@book> insert into t select rownum+2 from dual connect by level <=64000-2;
63998 rows created.
SCOTT@book> commit ;
Commit complete.
insert into t select * from t;
insert into t select * from t;
insert into t select * from t;
commit ;
--//分析表略.
SCOTT@book> select OWNER,SEGMENT_NAME,SEGMENT_TYPE,HEADER_FILE,HEADER_BLOCK,BYTES,BLOCKS from dba_segments where owner=user and segment_name='T';
OWNER SEGMENT_NAME SEGMENT_TYPE HEADER_FILE HEADER_BLOCK BYTES BLOCKS
------ -------------------- ------------------ ----------- ------------ ---------- ----------
SCOTT T TABLE 4 546 2153775104 262912
--//占用2153775104/1024/1024=2054M,262912块.
SCOTT@book> select object_id,data_object_id from dba_objects where owner=user and object_name='T';
OBJECT_ID DATA_OBJECT_ID
---------- --------------
90702 90702
2.测试1:
SCOTT@book> alter system flush buffer_cache;
System altered.
SCOTT@book> select count(*) from v$bh where OBJD=90702 and STATUS<>'free';
COUNT(*)
----------
0
SCOTT@book> select count(*) from t ;
COUNT(*)
----------
512000
SCOTT@book> @ &r/dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID 45vdc2q5hs1f3, child number 1
-------------------------------------
select count(*) from t
Plan hash value: 2966233522
----------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| E-Time | A-Rows | A-Time | Buffers | Reads |
----------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 71059 (100)| | 1 |00:00:01.24 | 256K| 256K|
| 1 | SORT AGGREGATE | | 1 | 1 | | | 1 |00:00:01.24 | 256K| 256K|
| 2 | TABLE ACCESS FULL| T | 1 | 512K| 71059 (1)| 00:14:13 | 512K|00:00:01.21 | 256K| 256K|
----------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1
2 - SEL$1 / T@SEL$1
SCOTT@book> select count(*) from v$bh where OBJD=90702 and STATUS<>'free';
COUNT(*)
----------
11
--//看reads=256K,仅仅缓存11块就能确定问题.现在是直接路径读.执行多次看执行依旧.
SCOTT@book> @ &r/viewsess "physical reads direct"
NAME STATISTIC# VALUE SID
------------------------------------------ ---------- ---------- ----------
physical reads direct 97 256064 274
physical reads direct temporary tablespace 110 0 274
physical reads direct (lob) 176 0 274
3.测试set events '10949 trace name context forever';
SCOTT@book> host oerr ora 10949
10949, 00000, "Disable autotune direct path read for full table scan"
// *Cause:
// *Action: Disable autotune direct path read for serial full table scan.
--//按照介绍应该这个也可以.
SCOTT@book> alter session set events '10949 trace name context forever';
Session altered.
SCOTT@book> alter session set statistics_level=all ;
Session altered.
SCOTT@book> alter system flush buffer_cache;
System altered.
SCOTT@book> select count(*) from v$bh where OBJD=90702 and STATUS<>'free';
COUNT(*)
----------
0
SCOTT@book> select count(*) from t ;
COUNT(*)
----------
512000
SCOTT@book> @ &r/dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID 45vdc2q5hs1f3, child number 1
-------------------------------------
select count(*) from t
Plan hash value: 2966233522
----------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| E-Time | A-Rows | A-Time | Buffers | Reads |
----------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 71059 (100)| | 1 |00:00:00.71 | 256K| 256K|
| 1 | SORT AGGREGATE | | 1 | 1 | | | 1 |00:00:00.71 | 256K| 256K|
| 2 | TABLE ACCESS FULL| T | 1 | 512K| 71059 (1)| 00:14:13 | 512K|00:00:00.69 | 256K| 256K|
----------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1
2 - SEL$1 / T@SEL$1
20 rows selected.
SCOTT@book> @ &r/viewsess "physical reads direct"
NAME STATISTIC# VALUE SID
------------------------------------------ ---------- ---------- ----------
physical reads direct 97 256064 274
physical reads direct temporary tablespace 110 0 274
physical reads direct (lob) 176 0 274
SCOTT@book> select count(*) from v$bh where OBJD=90702 and STATUS<>'free';
COUNT(*)
----------
11
--//看reads=256K,仅仅缓存11块就能确定问题.现在是直接路径读.执行多次看执行依旧.
--//说明设置set events '10949 trace name context forever';无法关闭直接路径读.
4.设置"_serial_direct_read"=never;
SCOTT@book> alter session set "_serial_direct_read"=never;
Session altered.
SCOTT@book> alter session set statistics_level=all ;
Session altered.
SCOTT@book> alter system flush buffer_cache;
System altered.
SCOTT@book> select count(*) from v$bh where OBJD=90702 and STATUS<>'free';
COUNT(*)
----------
0
SCOTT@book> select count(*) from v$bh where OBJD=90702 and STATUS<>'free';
COUNT(*)
----------
0
SCOTT@book> select count(*) from t ;
COUNT(*)
----------
512000
SCOTT@book> @ &r/dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID 45vdc2q5hs1f3, child number 1
-------------------------------------
select count(*) from t
Plan hash value: 2966233522
----------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| E-Time | A-Rows | A-Time | Buffers | Reads |
----------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 71059 (100)| | 1 |00:00:01.80 | 256K| 256K|
| 1 | SORT AGGREGATE | | 1 | 1 | | | 1 |00:00:01.80 | 256K| 256K|
| 2 | TABLE ACCESS FULL| T | 1 | 512K| 71059 (1)| 00:14:13 | 512K|00:00:01.78 | 256K| 256K|
----------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1
2 - SEL$1 / T@SEL$1
SCOTT@book> @ &r/viewsess "physical reads direct"
NAME STATISTIC# VALUE SID
---------------------------------------------------------------------- ---------- ---------- ----------
physical reads direct 97 0 274
physical reads direct temporary tablespace 110 0 274
physical reads direct (lob) 176 0 274
--//直接路径读为0
SCOTT@book> select count(*) from v$bh where OBJD=90702 and STATUS<>'free';
COUNT(*)
----------
49959
--//已经缓存了49959块.多次执行如下语句:
SCOTT@book> select count(*) from t ;
COUNT(*)
----------
512000
SCOTT@book> @ &r/dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID 45vdc2q5hs1f3, child number 1
-------------------------------------
select count(*) from t
Plan hash value: 2966233522
----------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| E-Time | A-Rows | A-Time | Buffers | Reads |
----------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 71059 (100)| | 1 |00:00:01.37 | 256K| 217K|
| 1 | SORT AGGREGATE | | 1 | 1 | | | 1 |00:00:01.37 | 256K| 217K|
| 2 | TABLE ACCESS FULL| T | 1 | 512K| 71059 (1)| 00:14:13 | 512K|00:00:01.35 | 256K| 217K|
----------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1
2 - SEL$1 / T@SEL$1
20 rows selected.
--//你可以发现读的数量降到了217K块.
总结:
--//测试一定要注意一些oracle版本的变化,一些参数可能随着版本的变化发生变化.
--//这也是我为什么每次写blog都指明我当前的使用版本.
--//关闭直接路径读alter session set "_serial_direct_read"=never;对于11GR2才有效.
[20171120]11G关闭直接路径读.txt的更多相关文章
- [20180316]共享服务模式和直接路径读.txt
[20180316]共享服务模式和直接路径读.txt --//在共享服务器模式下,执行计划不会选择直接路径读,通过例子证明. 1.环境:SYS@book> @ &r/ver1PORT_S ...
- [20180319]直接路径读特例12c.txt
[20180319]直接路径读特例12c.txt --//昨天的测试突然想起以前遇到的直接路径读特例,在12c重复测试看看. 1.环境:SCOTT@test01p> @ ver1 PORT_ST ...
- 11g直接路径读、相关参数、10949事件介绍
转载自刘向兵老师:http://www.askmaclean.com/archives/11g-direct-path-read-10949-_small_table_threshold-_seria ...
- [20171120]11g select for update skip locked.txt
[20171120]11g select for update skip locked.txt --//11G在select for update遇到阻塞时可以通过skipped locked跳过阻塞 ...
- matlab文件操作及读txt文件(fopen,fseek,fread,fclose)
文件操作是一种重要的输入输出方式,即从数据文件读取数据或将结果写入数据文件.MATLAB提供了一系列低层输入输出函数,专门用于文件操作. 1.文件的打开与关闭 1)打开文件 在读写文件之前,必须先用f ...
- Oracle 直接路径读
在11g中,全表扫描可能使用direct path read方式,绕过buffer cache,这样的全表扫描就是物理读了. 在10g中,都是通过gc buffer来读的,所以不存在direct pa ...
- MATLAB文件操作及读txt文件
转自:http://blog.csdn.net/vblittleboy/article/details/8049748 文件操作是一种重要的输入输出方式,即从数据文件读取数据或将结果写入数据文件.MA ...
- direct path read/write (直接路径读/写)
转载:http://www.dbtan.com/2010/04/direct-path-readwrite.html direct path read/write (直接路径读/写): 直接路径读(d ...
- Oracle收集对表收集统计信息导致全表扫描直接路径读?
direct path read深入解析 前言 最近碰到一件很奇葩的事情,因为某条SQL执行缓慢,原因是走了笛卡尔(两组大数据结果集),而且笛卡尔还是NL的一个部分,要循环31M次. 很容易发现是统计 ...
随机推荐
- ffmpeg 实现多宫格效果,视频拼接合成
通过FFmpeg建立画布,以多宫格方式展现 一下为执行命令 -re -i 1.mp4 -re -i 2.mp4 -re -i 3.mp4 -re -i 4.mp4 -filter_complex &q ...
- [EXP]Joomla! Component Easy Shop 1.2.3 - Local File Inclusion
# Exploit Title: Joomla! Component Easy Shop - Local File Inclusion # Dork: N/A # Date: -- # Exploit ...
- Python内置常量
引言 Python内置的常量不多,只有6个,分别是True.False.None.NotImplemented.Ellipsis.__debug__. 一. True 1. True是bool类型用来 ...
- 正则表达式matcher.group用法
group是针对括号()来说的,group(0)就是指的整个串,group(1) 指的是第一个括号里的东西,group(2)指的第二个括号里的东西. 上代码: @Test public void te ...
- msysGit在GitHub代码托管
(转:http://www.cnblogs.com/xing901022/p/4388190.html) 代码的管理,在日常开发中是很重要的环节,程序员的修炼三部曲——版本控制,单元测试,项目自动化. ...
- vue页面参数闪一下的问题
解决方法: 直接在外层元素加上v-cloak <div id='app' v-cloak></div>
- salesforce lightning零基础学习(七) 列表展示数据时两种自定义编辑页面
上一篇Lightning内容描述的是LDS,通过LDS可以很方便的实例化一个对象的数据信息.当我们通过列表展示数据需要编辑时,我们常使用两种方式去处理编辑页面:Pop Up Window弹出修改详情以 ...
- 多线程读者写者问题--用QT实现
先把代码贴上来,有时间再整理吧..因为工作中用Qt,所以用Qt实现的....刚上班,,忙! 三种方法,读者优先,写者优先和公平竞争.. 读者优先 #include <QCoreApplicati ...
- 国内高速Maven仓库
<mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> & ...
- Django 学习笔记(一) --- Hello Django
人生苦短 ~ Tips:仅适用于 Python 3+(反正差别不大,py2 改改也能用).因为据 Python 之父 Guido van Rossum 说会在 2020 年停止对 Python 2 的 ...