[20180319]直接路径读特例12c.txt

--//昨天的测试突然想起以前遇到的直接路径读特例,在12c重复测试看看.

1.环境:
SCOTT@test01p> @ ver1

PORT_STRING                    VERSION        BANNER                                                                               CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0           12.1.0.1.0     Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production              0

SCOTT@test01p> create table t as select * from all_objects order by  DBMS_RANDOM.random;
Table created.

SCOTT@test01p> create index i_t_object_id on t(object_id);
Index created.

SCOTT@test01p> select data_object_id,object_id from dba_objects where owner=user and object_name='T';
DATA_OBJECT_ID  OBJECT_ID
-------------- ----------
        107151     107151

--//分析.
execute sys.dbms_stats.gather_table_stats ( OwnName => nvl('',user),TabName => 't',Estimate_Percent => NULL,Method_Opt => 'FOR ALL COLUMNS SIZE 1 ',Cascade => True ,No_Invalidate => false)

SCOTT@test01p> select rowid ,owner from t where object_id  between  1 and 10;
ROWID              OWNER
------------------ --------------------
AAAaKPAAJAAAAY7AAE SYS
AAAaKPAAJAAAAaWAAP SYS
AAAaKPAAJAAAARtAAd SYS
AAAaKPAAJAAAAK5AAw SYS
AAAaKPAAJAAAAbGAAV SYS
AAAaKPAAJAAAAIFAAK SYS
AAAaKPAAJAAAASIAAB SYS
AAAaKPAAJAAAAMIAAQ SYS
AAAaKPAAJAAAAOMAAp SYS
9 rows selected.

2.测试:
SCOTT@test01p> alter system flush buffer_cache ;
System altered.

SCOTT@test01p> alter session set statistics_level=all;
Session altered.

SCOTT@test01p> select rowid ,owner,object_id from t where rowid between 'AAAaKPAAJAAAAY7AAE' and 'AAAaKPAAJAAAAY7AAF';

ROWID              OWNER                 OBJECT_ID
------------------ -------------------- ----------
AAAaKPAAJAAAAY7AAE SYS                           2
AAAaKPAAJAAAAY7AAF SYS                       10575

Plan hash value: 280204748
---------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                   | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers | Reads  |
---------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |      |      1 |        |       |   421 (100)|          |      2 |00:00:00.07 |       5 |      2 |
|*  1 |  TABLE ACCESS BY ROWID RANGE| T    |      1 |    225 |  5175 |   421   (1)| 00:00:01 |      2 |00:00:00.07 |       5 |      2 |
---------------------------------------------------------------------------------------------------------------------------------------

Plan hash value: 280204748
---------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                   | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers | Reads  |
---------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |      |      1 |        |       |   421 (100)|          |      2 |00:00:00.01 |       5 |      1 |
|*  1 |  TABLE ACCESS BY ROWID RANGE| T    |      1 |    225 |  5175 |   421   (1)| 00:00:01 |      2 |00:00:00.01 |       5 |      1 |
---------------------------------------------------------------------------------------------------------------------------------------

--//多次执行总存在一个物理读.

SCOTT@test01p> @ viewsess 'physical reads direct%'
NAME                                                                   STATISTIC#  VALUE        SID
---------------------------------------------------------------------- ---------- ------ ----------
physical reads direct                                                          91      4        242
physical reads direct temporary tablespace                                    104      0        242
physical reads direct (lob)                                                   170      0        242
physical reads direct for securefile flashback block new                      181      0        242

SCOTT@test01p> select rowid ,owner,object_id from t where rowid between 'AAAaKPAAJAAAAY7AAE' and 'AAAaKPAAJAAAAY7AAF';
ROWID              OWNER                 OBJECT_ID
------------------ -------------------- ----------
AAAaKPAAJAAAAY7AAE SYS                           2
AAAaKPAAJAAAAY7AAF SYS                       10575

SCOTT@test01p> @ viewsess 'physical reads direct%'
NAME                                                                   STATISTIC#  VALUE        SID
---------------------------------------------------------------------- ---------- ------ ----------
physical reads direct                                                          91      5        242
physical reads direct temporary tablespace                                    104      0        242
physical reads direct (lob)                                                   170      0        242
physical reads direct for securefile flashback block new                      181      0        242

3.不过如果where rowid between 'AAAaKPAAJAAAAY7AAE' and 'AAAaKPAAJAAAAY7AAE';
SCOTT@test01p> select rowid ,owner,object_id from t where rowid between 'AAAaKPAAJAAAAY7AAE' and 'AAAaKPAAJAAAAY7AAE';
ROWID              OWNER                 OBJECT_ID
------------------ -------------------- ----------
AAAaKPAAJAAAAY7AAE SYS                           2

SCOTT@test01p> @ viewsess 'physical reads direct%'
NAME                                                                   STATISTIC#  VALUE        SID
---------------------------------------------------------------------- ---------- ------ ----------
physical reads direct                                                          91      5        242
physical reads direct temporary tablespace                                    104      0        242
physical reads direct (lob)                                                   170      0        242
physical reads direct for securefile flashback block new                      181      0        242

--//physical reads direct没有增加.

SCOTT@test01p> select file#,block#,status from v$bh where OBJD=107151 and STATUS<>'free';
     FILE#     BLOCK# STATUS
---------- ---------- --------------------
         9        186 xcur
         9       1595 xcur

SCOTT@test01p> @ rowid AAAaKPAAJAAAAY7AAE
    OBJECT       FILE      BLOCK        ROW ROWID_DBA            DBA                  TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
    107151          9       1595          4  0x240063B           9,1595               alter system dump datafile 9 block 1595

--//rowid='AAAaKPAAJAAAAY7AAE'已经进入数据缓存.

SCOTT@test01p> select header_file,header_block from dba_segments where owner=user and segment_name='T';
HEADER_FILE HEADER_BLOCK
----------- ------------
          9          186

--//dba =9 , 186 对应 段头.
--//我一直不明白为什么oracle要这样设计.12c与11g的测试一样.
--//还有1点不明白的地方就是:
select rowid ,owner,object_id from t where rowid between 'AAAaKPAAJAAAASIAAB' and 'AAAaKPAAJAAAASIAAC';

Plan hash value: 280204748
---------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                   | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers | Reads  |
---------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |      |      1 |        |       |   421 (100)|          |      2 |00:00:00.04 |       5 |      1 |
|*  1 |  TABLE ACCESS BY ROWID RANGE| T    |      1 |      2 |    46 |   421   (1)| 00:00:01 |      2 |00:00:00.04 |       5 |      1 |
---------------------------------------------------------------------------------------------------------------------------------------

select rowid ,owner,object_id from t where rowid between 'AAAaKPAAJAAAASIAAB' and 'AAAaKPAAJAAAASIAAB';
Plan hash value: 3207308387
-----------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                  | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers |
-----------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT           |      |      1 |        |       |     1 (100)|          |      1 |00:00:00.01 |       1 |
|   1 |  TABLE ACCESS BY USER ROWID| T    |      1 |      1 |    23 |     1   (0)| 00:00:01 |      1 |00:00:00.01 |       1 |
-----------------------------------------------------------------------------------------------------------------------------

--//为什么前者逻辑读是5,而后者为1.

ALTER SESSION SET EVENTS '10200 TRACE NAME CONTEXT FOREVER, LEVEL 1';
select rowid ,owner,object_id from t where rowid between 'AAAaKPAAJAAAASIAAB' and 'AAAaKPAAJAAAASIAAC';
ALTER SESSION SET EVENTS '10200 TRACE NAME CONTEXT off';

D:\tools\rlwrap>grep "started" D:\app\oracle\diag\rdbms\test\test\trace\test_ora_5280.trc
grep "started" D:\app\oracle\diag\rdbms\test\test\trace\test_ora_5280.trc
ktrget3(): started for block  <0x0003 : 0x02400488> objd: 0x0001a28f
ktrget3(): started for block  <0x0003 : 0x02400488> objd: 0x0001a28f

--//转储内容:
ktrget3(): started for block  <0x0003 : 0x02400488> objd: 0x0001a28f
env [0x0000000002197E9C]: (scn: 0x0000.019be656   xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  statement num=0  parent xid:  0x0000.000.00000000  st-scn: 0x0000.00000000  hi-scn: 0x0000.00000000  ma-scn: 0x0000.019be619  flg: 0x00000661)
ktrgcm(): completed for block  <0x0003 : 0x02400488> objd: 0x0001a28f
ktrget3(): completed for  block <0x0003 : 0x02400488> objd: 0x0001a28f
ktrget3(): started for block  <0x0003 : 0x02400488> objd: 0x0001a28f
env [0x0000000002197E9C]: (scn: 0x0000.019be656   xid: 0x0000.000.00000000  uba: 0x00000000.0000.00  statement num=0  parent xid:  0x0000.000.00000000  st-scn: 0x0000.00000000  hi-scn: 0x0000.00000000  ma-scn: 0x0000.019be619  flg: 0x00000660)
ktrgcm(): completed for block  <0x0003 : 0x02400488> objd: 0x0001a28f
ktrget3(): completed for  block <0x0003 : 0x02400488> objd: 0x0001a28f

SCOTT@test01p> @ 10046on 12
old   1: alter session set events '10046 trace name context forever, level &1'
new   1: alter session set events '10046 trace name context forever, level 12'
Session altered.

SCOTT@test01p> select rowid ,owner,object_id from t where rowid between 'AAAaKPAAJAAAASIAAB' and 'AAAaKPAAJAAAASIAAC';
ROWID              OWNER                 OBJECT_ID
------------------ -------------------- ----------
AAAaKPAAJAAAASIAAB SYS                           8
AAAaKPAAJAAAASIAAC SYS                       10174

SCOTT@test01p> @ 10046off
Session altered.

=====================
PARSING IN CURSOR #35276568 len=102 dep=0 uid=109 oct=3 lid=109 tim=5262812718 hv=3900635955 ad='7ff13b72e40' sqlid='c5tpurvn7xytm'
select rowid ,owner,object_id from t where rowid between 'AAAaKPAAJAAAASIAAB' and 'AAAaKPAAJAAAASIAAC'
END OF STMT
PARSE #35276568:c=15600,e=5133,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,plh=280204748,tim=5262812715
EXEC #35276568:c=0,e=78,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=280204748,tim=5262813350
WAIT #35276568: nam='SQL*Net message to client' ela= 4 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=5262813588
WAIT #35276568: nam='Disk file operations I/O' ela= 598 FileOperation=2 fileno=9 filetype=2 obj#=107151 tim=5262814790
WAIT #35276568: nam='direct path read' ela= 40173 file number=9 first dba=1160 block cnt=1 obj#=107151 tim=5262855268
FETCH #35276568:c=0,e=41975,p=1,cr=4,cu=0,mis=0,r=1,dep=0,og=1,plh=280204748,tim=5262855697
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> CR=4,为什么?
WAIT #35276568: nam='SQL*Net message from client' ela= 2441 driver id=1413697536 #bytes=1 p3=0 obj#=107151 tim=5262858326
WAIT #35276568: nam='SQL*Net message to client' ela= 4 driver id=1413697536 #bytes=1 p3=0 obj#=107151 tim=5262858682
FETCH #35276568:c=0,e=332,p=0,cr=1,cu=0,mis=0,r=1,dep=0,og=1,plh=280204748,tim=5262858968
STAT #35276568 id=1 cnt=2 pid=0 pos=1 obj=107151 op='TABLE ACCESS BY ROWID RANGE T (cr=5 pr=1 pw=0 time=41932 us cost=421 size=5175 card=225)'

*** 2018-03-19 21:34:02.984
WAIT #35276568: nam='SQL*Net message from client' ela= 4953864 driver id=1413697536 #bytes=1 p3=0 obj#=107151 tim=5267820265
CLOSE #35276568:c=0,e=32,dep=0,type=0,tim=5267820714
=====================

[20180319]直接路径读特例12c.txt的更多相关文章

  1. [20180316]共享服务模式和直接路径读.txt

    [20180316]共享服务模式和直接路径读.txt --//在共享服务器模式下,执行计划不会选择直接路径读,通过例子证明. 1.环境:SYS@book> @ &r/ver1PORT_S ...

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

    [20171120]11G关闭直接路径读.txt --//今天做filesystemio_options参数测试时,遇到一个关于直接路径读的问题.--//如果看以前的博客介绍,设置"_ser ...

  3. Oracle 直接路径读

    在11g中,全表扫描可能使用direct path read方式,绕过buffer cache,这样的全表扫描就是物理读了. 在10g中,都是通过gc buffer来读的,所以不存在direct pa ...

  4. 11g直接路径读、相关参数、10949事件介绍

    转载自刘向兵老师:http://www.askmaclean.com/archives/11g-direct-path-read-10949-_small_table_threshold-_seria ...

  5. [20170612]FOR ALL COLUMNS SIZE repeat(12c).txt

    [20170612]FOR ALL COLUMNS SIZE repeat(12c).txt --//昨天看了https://jonathanlewis.wordpress.com/2017/06/0 ...

  6. direct path read/write (直接路径读/写)

    转载:http://www.dbtan.com/2010/04/direct-path-readwrite.html direct path read/write (直接路径读/写): 直接路径读(d ...

  7. [20190524]DISABLE TABLE LOCK(12c).txt

    [20190524]DISABLE TABLE LOCK(12c).txt --//如果禁止table lock时,一些ddl操作会被禁止.但是我有点吃惊的是增加字段不受限制.--//链接:http: ...

  8. [转帖]direct path read直接路径读

    direct path read直接路径读 http://blog.itpub.net/12679300/viewspace-1188072/ 原创 Oracle 作者:wzq609 时间:2014- ...

  9. Oracle收集对表收集统计信息导致全表扫描直接路径读?

    direct path read深入解析 前言 最近碰到一件很奇葩的事情,因为某条SQL执行缓慢,原因是走了笛卡尔(两组大数据结果集),而且笛卡尔还是NL的一个部分,要循环31M次. 很容易发现是统计 ...

随机推荐

  1. 课程四(Convolutional Neural Networks),第二 周(Deep convolutional models: case studies) —— 2.Programming assignments : Keras Tutorial - The Happy House (not graded)

    Keras tutorial - the Happy House Welcome to the first assignment of week 2. In this assignment, you ...

  2. Git工具使用

    GIT(分布式版本控制系统) Git是一款免费.开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目.Git的读音为/gɪt/. Git是一个开源的分布式版本控制系统,可以有效.高速的处理从 ...

  3. mysql 开发进阶篇系列 33 工具篇(mysqlbinlog日志管理工具)

    一.概述 由于服务器生成的二进制日志文件以二进制格式保存,所以如果要想检查这些文件的文本格式,就会用到mysqlbinlog日志管理工具. mysqlbinlog的语法如下: mysqlbinlog ...

  4. Docker应用场景

    Docker的应用场景 Web 应用的自动化打包和发布. 自动化测试和持续集成.发布. 在服务型环境中部署和调整数据库或其他的后台应用. 从头编译或者扩展现有的OpenShift或Cloud Foun ...

  5. Java设计模式学习记录-GoF设计模式概述

    前言 最近要开始学习设计模式了,以前是偶尔会看看设计模式的书或是在网上翻到了某种设计模式,就顺便看看,也没有仔细的学习过.前段时间看完了JVM的知识,然后就想着JVM那么费劲的东西都看完了,说明自己学 ...

  6. Java设计模式学习记录-享元模式

    前言 享元模式也是一种结构型模式,这篇是介绍结构型模式的最后一篇了(因为代理模式很早之前就已经写过了).享元模式采用一个共享来避免大量拥有相同内容对象的开销.这种开销最常见.最直观的就是内存损耗. 享 ...

  7. jQuery validate and groups - how to avoid errorPlacement usage?

    本文参照:https://stackoverflow.com/questions/14146893/using-groups-with-jquery-form-validation-how 指定错误提 ...

  8. oracle用户权限

    权限: create session create table unlimited tablespace connect resource dba 例: #sqlplus /nolog SQL> ...

  9. asp.net前台页面与后台之间传值,

     在前台用 js 获取到的 “值 ”需要传到后台,在后台调用,    ******  原有传入的 “值 ” 不要被覆盖     1.最简单的在页面写一个隐藏表单,隐藏标签,把获取到的值赋给隐藏标签之后 ...

  10. mysql游标中使用临时表

    有时候需我们要组合几张表的数据,在存储过程中,经过比较复杂的运算获取结果直接输出给调用方,比如符合条件的几张表的某些字段的组合计算,mysql临时表可以解决这个问题. 所谓临时表:只有在当前连接情况下 ...