[20171120]11G关闭直接路径读.txt

简介: [20171120]11G关闭直接路径读.txt --//今天做filesystemio_options参数测试时,遇到一个关于直接路径读的问题. --//如果看以前的博客介绍,设置"_serial_direct_read"=never或者events '10949 trace name context forever';就可以关闭直接路径读.

[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才有效.

目录
相关文章
|
4月前
|
Java
File常用的方法操作、在磁盘上创建File、获取指定目录下的所有文件、File文件的重命名、将数据写入File文件
这篇文章介绍了Java中`File`类的常用方法操作,包括文件和目录路径名的抽象表示、构造方法、常用方法以及代码实例。文章通过具体的代码示例,展示了如何在磁盘上创建文件和目录、处理目录存在的情况、文件重命名、获取指定目录下的所有文件以及将数据写入文件等操作。每个代码实例都配有测试结果截图,帮助读者更好地理解和掌握`File`类的应用。
File常用的方法操作、在磁盘上创建File、获取指定目录下的所有文件、File文件的重命名、将数据写入File文件
|
4月前
|
JavaScript Java
不同目录下的文件读取方式
这篇文章介绍了在Java中不同情况下读取文件的方法,包括当文件与类文件处于同级目录、不同级目录,以及不区分目录层级时的读取方式。
32 1
|
7月前
|
存储 文件存储
<文件操作> 文件的打开与关闭,顺序读写,随机读写,二进制文件,读取结束的判定,文件缓冲区
<文件操作> 文件的打开与关闭,顺序读写,随机读写,二进制文件,读取结束的判定,文件缓冲区
44 1
|
Go Python
Go-文件目录操作分类详解(创建、打开、关闭、读取、写入、判断等)
Go-文件目录操作分类详解(创建、打开、关闭、读取、写入、判断等)
437 0
Go-文件目录操作分类详解(创建、打开、关闭、读取、写入、判断等)
|
Linux Go Windows
【GO】文件读写:打开关闭+打开模式+文件权限+文件读取
【GO】文件读写:打开关闭+打开模式+文件权限+文件读取
411 0
【GO】文件读写:打开关闭+打开模式+文件权限+文件读取
vbs 读取txt是读取特定的行
读取第三行的内容:Set fso = CreateObject("scripting.filesystemobject")path="A.TXT文件的路径"Set A=fso.OpenTextFile(path,1)For i=1 To 2A.
1104 0
|
缓存 网络协议 关系型数据库
[20180316]共享服务模式和直接路径读.txt
[20180316]共享服务模式和直接路径读.txt --//在共享服务器模式下,执行计划不会选择直接路径读,通过例子证明. 1.环境: SYS@book> @ &r/ver1 PORT_STRING          VERSION    BANNER...
873 0
|
Oracle 关系型数据库 Linux
[20180211]11g关闭AMM.txt
[20180211]11g关闭AMM.txt --//指点别人的系统关闭AMM,使用hugepages遇到问题,主要问题是对方设置如下参数在spfile文件中: *.
1315 0