[20180319]直接路徑讀特例12c.txt

来源:https://www.cnblogs.com/lfree/archive/2018/03/20/8606996.html
-Advertisement-
Play Games

[20180319]直接路徑讀特例12c.txt--//昨天的測試突然想起以前遇到的直接路徑讀特例,在12c重覆測試看看.1.環境:SCOTT@test01p> @ ver1PORT_STRING VERSION BANNER CON_ID IBMPC/WIN_NT64-9.1.0 12.1.0.1 ...


[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
=====================


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 1.Centos 6.5的預設yum源可以直接安裝httpd服務 1 [root@httpd ~]# ll /etc/yum.repos.d/ 2 total 24 3 -rw-r--r--. 1 root root 1926 Nov 27 2013 CentOS-Base.repo 4 -rw-r ...
  • 1.1 jumpserver安裝 同步時間:ntpdate ntp1.aliyun.com 關閉selinux 關閉防火牆 系統字體修改成英文 1.1.1 安裝依賴(前提需要epel源) yum install -y git python-pip mariadb-devel gcc automake ...
  • 本文由“汽車電子expert成長之路”公眾號中“S12(X)系列MCU的片上存儲器資源與分頁訪問機制詳解”文章整理得來 最近接觸S12MCU中關於FLASH的擦寫相關知識,需要捋清楚幾個概念。 (16位單片機) 具體記憶體分配看 MC9S12G系列晶元手冊中 40 頁 本地地址(Local Addre ...
  • 配置Apache提示報錯configure error: APR could not be located. Please use the --with-apr option. 解決辦法: ./configure --prefix=usr/local/apache/ --with-apr=/usr/ ...
  • 在mac版本AppStore下載軟體的時候,有時會出現“This item is temporarily unavailable, Try again later”錯誤提示,當然等一會兒或者不斷重新嘗試都是無法下載的。 "StackOverFlow" 上找到一個解法: Mac App Store S ...
  • linux系統概述,linux系統的發行版有哪些,linux的存儲設備,linux的目錄結構的簡單介紹 ...
  • 啟動Apache提示報錯:Could not reliably determine the server's fully qualified domain name, using localhost,localdomain . Set the 'ServerName' directive globa ...
  • 1.點擊右上角的按鈕 2.選擇要登錄的客戶名字 點擊進入 3.輸入賬號密碼 進入指定的賬號 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...