如何使用SQL_TRACE和10046事件

kingsql發表於2015-07-23

Eygle大師的微信講堂昨天開課,第一堂課和大家分享了一些學習Oracle的基本方法,其中提到了使用SQL_TRACE10046事件。SQL_TRACEOracle提供的用於進行SQL跟蹤的手段,是強有力的輔助診斷工具。在日常的資料庫問題診斷和解決中,SQL_TRACE是非常常用的方法。

      對於這個工具,我很早就聽過,但是從來就沒用過,“紙上得來終覺淺,絕知此事要躬行”,操練起來。

1.環境準備

      我們在Oracle11g中進行測試。

點選(此處)摺疊或開啟

  1. SQL>
  2. SQL> select * from v$version;

  3. BANNER
  4. --------------------------------------------------------------------------------
  5. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
  6. PL/SQL Release 11.2.0.3.0 - Production
  7. CORE 11.2.0.3.0 Production
  8. TNS for Linux: Version 11.2.0.3.0 - Production
  9. NLSRTL Version 11.2.0.3.0 - Production

  10. SQL>

2.啟用SQL_TRACE

      Oracle中初始化設定中SQL_TRACE預設是關閉的,它可以作為初始化引數在全域性啟用,也可以透過命令列方式在具體session啟用。

1. 在全域性啟用

在引數檔案(pfile/spfile)中指定:

SQL_TRACE =true

在全域性啟用SQL_TRACE會導致所有程式的活動被跟蹤,包括後臺程式及所有使用者程式,這通常會導致比較嚴重的效能問題,所以在生產環境中要謹慎使用,這個引數在10g之後是動態引數,可以隨時調整,在某些診斷中非常有效。

提示: 透過在全域性啟用SQL_TRACE,我們可以跟蹤到所有後臺程式的活動,很多在文件中的抽象說明,透過跟蹤檔案的實時變化,我們可以清晰的看到各個程式之間的緊密協調。

2. 在當前session級設定

      大多數時候我們使用SQL_TRACE跟蹤當前程式.透過跟蹤當前程式可以發現當前操作的後臺資料庫遞迴活動(這在研究資料庫新特性時尤其有效),研究SQL執行,發現後臺錯誤等。

     我在測試中啟用session級別的SQL_TRACE,如下所示。

點選(此處)摺疊或開啟

  1. SQL>
  2. SQL> show parameter SQL_TRACE

  3. NAME TYPE VALUE
  4. ------------------------------------ ----------- ------------------------------
  5. SQL_TRACE boolean FALSE
  6. SQL>
  7. SQL> alter session set SQL_TRACE=true;

  8. Session altered.

  9. SQL>
  10. SQL> show parameter SQL_TRACE

  11. NAME TYPE VALUE
  12. ------------------------------------ ----------- ------------------------------
  13. SQL_TRACE boolean TRUE
  14. SQL>

3.連線soctt使用者,執行查詢語句

     登陸scott使用者,執行兩條簡單的查詢語句。

點選(此處)摺疊或開啟

  1. [oracle@hoegh admin]$ sqlplus scott/tiger

  2. SQL*Plus: Release 11.2.0.3.0 Production on Wed May 27 09:59:48 2015

  3. Copyright (c) 1982, 2011, Oracle. All rights reserved.


  4. Connected to:
  5. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
  6. With the Partitioning, OLAP, Data Mining and Real Application Testing options

  7. SQL> select * from cat;

  8. TABLE_NAME TABLE_TYPE
  9. ------------------------------ -----------
  10. BONUS TABLE
  11. DEPT TABLE
  12. EMP TABLE
  13. SALGRADE TABLE

  14. SQL> select * from dept;

  15.     DEPTNO DNAME LOC
  16. ---------- -------------- -------------
  17.         10 ACCOUNTING NEW YORK
  18.         20 RESEARCH DALLAS
  19.         30 SALES CHICAGO
  20.         40 OPERATIONS BOSTON

4.生成trace檔案

plustrace角色

      和Oracle10g一樣,11g中plustrace角色預設也是disabled的。如果使用非授權使用者開啟Oracle trace功能會得到以下的錯誤。

點選(此處)摺疊或開啟

  1. SQL>
  2. SQL> show user
  3. USER is \"SCOTT\"
  4. SQL>
  5. SQL> set autotrace on
  6. SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled
  7. SP2-0611: Error enabling STATISTICS report
  8. SQL>
     
這時需要執行$ORACLE_HOME/sqlplus/admin/plustrce.sql指令碼,手工建立plustrace角色,在此不做演示。因為我們更多的時候是需要跟蹤其他使用者的程式,而很多這樣的使用者可能沒有被授予或者不允許授予plustrace角色。這時可以使用DBMS_SYSTEM包來實現對程式的跟蹤,這兒需要提供使用者程式的sid和serial#。

10046事件

     在這兒就不得不提到10046事件,10046事件是Oracle提供的內部事件,是對SQL_TRACE的增強。

10046事件可以設定以下四個級別:

1 - 啟用標準的SQL_TRACE功能,等價於SQL_TRACE

4 - Level 1 加上繫結值(bind values)

8 - Level 1 + 等待事件跟蹤

12 - Level 1 + Level 4 + Level 8

      和SQL_TRACE類似,10046事件可以在全域性設定,也可以在session級設定。

生成trace檔案

     首先,我們透過查詢v$session檢視獲取scott使用者程式的sid和serial#;
     然後執行dbms_system.set_ev
過程來實現對程式的跟蹤。

點選(此處)摺疊或開啟

  1. SQL>
  2. SQL> select sid,serial#,username from v$session where username=\'SCOTT\';

  3.        SID SERIAL# USERNAME
  4. ---------- ---------- ------------------------------
  5.         21 2615 SCOTT

  6. SQL>
  7. SQL> exec dbms_system.set_ev(21,2615,10046,12,\'SCOTT\');

  8. PL/SQL procedure successfully completed.

  9. SQL>

5.檢視trace檔案

存放目錄

      在11g中trace檔案的存放目錄有了變化,其中,11gR1 或 11gR1 以上版本可以透過查詢diagnostic_dest引數獲得;而11gR1以前版本則是透過user_dump_dest引數來指定。

點選(此處)摺疊或開啟

  1. SQL> show parameter diagnostic_dest

  2. NAME TYPE VALUE
  3. ------------------------------------ ----------- ------------------------------
  4. diagnostic_dest string /u01/app/oracle
  5. SQL>
     
在測試資料庫中,trace檔案的具體路徑為:/u01/app/oracle/diag/rdbms/hoegh/HOEGH/trace/

檢視trace檔案

      tracefile 命名規則 :_ora_.trc,其中pid為相應session所對應的OS PID。根據生成時間在/u01/app/oracle/diag/rdbms/hoegh/HOEGH/trace目錄下找到了trace檔案HOEGH_ora_16427.trc。我們透過more命令檢視檔案內容,由於內容較多,只擷取了開始部分內容如下。

點選(此處)摺疊或開啟

  1. [oracle@hoegh trace]$ more HOEGH_ora_16427.trc
  2. Trace file /u01/app/oracle/diag/rdbms/hoegh/HOEGH/trace/HOEGH_ora_16427.trc
  3. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
  4. With the Partitioning, OLAP, Data Mining and Real Application Testing options
  5. ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1
  6. System name: Linux
  7. Node name: hoegh.example.com
  8. Release: 2.6.18-164.el5PAE
  9. Version: #1 SMP Thu Sep 3 02:28:20 EDT 2009
  10. Machine: i686
  11. VM name: VMWare Version: 6
  12. Instance name: HOEGH
  13. Redo thread mounted by this instance: 1
  14. Oracle process number: 23
  15. Unix process pid: 16427, image: oracle@hoegh.example.com (TNS V1-V3)


  16. *** 2015-05-27 09:56:36.240
  17. *** SESSION ID:(142.1705) 2015-05-27 09:56:36.240
  18. *** CLIENT ID:() 2015-05-27 09:56:36.240
  19. *** SERVICE NAME:(SYS$USERS) 2015-05-27 09:56:36.240
  20. *** MODULE NAME:(sqlplus@hoegh.example.com (TNS V1-V3)) 2015-05-27 09:56:36.2
  21. 40
  22. *** ACTION NAME:() 2015-05-27 09:56:36.240
     
由於trace檔案的可讀性差,我們使用tkprof對trace檔案進行格式化,以下是格式化後的資訊內容,在這兒也只擷取了開始部門,完整的內容貼到文件的最後供大家參考。

格式化trace檔案


點選(此處)摺疊或開啟

  1. [oracle@hoegh trace]$ tkprof HOEGH_ora_16427.trc 10046.txt

  2. TKPROF: Release 11.2.0.3.0 - Development on Wed May 27 11:20:36 2015

  3. Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.


  4. [oracle@hoegh trace]$

檢視格式化後的trace報告


點選(此處)摺疊或開啟

  1. [oracle@hoegh trace]$ more 10046.txt

  2. TKPROF: Release 11.2.0.3.0 - Development on Wed May 27 11:20:36 2015

  3. Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.


  4. [oracle@ hoegh trace]$



  5. TKPROF: Release 11.2.0.3.0 - Development on Wed May 27 10:06:10 2015

  6. Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

  7. Trace file: HOEGH_ora_16427.trc
  8. Sort options: default

  9. ********************************************************************************
  10. count = number of times OCI procedure was executed
  11. cpu = cpu time in seconds executing
  12. elapsed = elapsed time in seconds executing
  13. disk = number of physical reads of buffers from disk
  14. query = number of buffers gotten for consistent read
  15. current = number of buffers gotten in current mode (usually for update)
  16. rows = number of rows processed by the fetch or execute call
  17. ********************************************************************************

  18. SQL ID: 4tk6t8tfsfqbf Plan Hash: 0

  19. alter session set sql_trace=true


  20. call count cpu elapsed disk query current rows
  21. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  22. Parse 0 0.00 0.00 0 0 0 0
  23. Execute 1 0.00 0.00 0 0 0 0
  24. Fetch 0 0.00 0.00 0 0 0 0
  25. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  26. total 1 0.00 0.00 0 0 0 0
      以上內容實現了一個應用sql_trace的簡單案例,trace檔案的資訊量較大,我將會在下一篇文章中和大家分享。  

大師論點

     Eygle在課堂上提到他在面試時經常問的一個問題,“在什麼技術上你做過深入思考得到了自己的觀點”,絕大多數人的回答都是NO。
     Eygle提倡由點及面、由淺入深的學習方法,確實,不深入是不可能有收穫的。
     
     期待下一次eygle在微信講堂的精彩分享。

hoegh
15.05.22
-- The End --

附完整trace報告            


點選(此處)摺疊或開啟

  1. TKPROF: Release 11.2.0.3.0 - Development on Wed May 27 11:20:36 2015

  2. Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.


  3. [oracle@ hoegh trace]$



  4. TKPROF: Release 11.2.0.3.0 - Development on Wed May 27 10:06:10 2015

  5. Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

  6. Trace file: HOEGH_ora_16427.trc
  7. Sort options: default

  8. ********************************************************************************
  9. count = number of times OCI procedure was executed
  10. cpu = cpu time in seconds executing
  11. elapsed = elapsed time in seconds executing
  12. disk = number of physical reads of buffers from disk
  13. query = number of buffers gotten for consistent read
  14. current = number of buffers gotten in current mode (usually for update)
  15. rows = number of rows processed by the fetch or execute call
  16. ********************************************************************************

  17. SQL ID: 4tk6t8tfsfqbf Plan Hash: 0

  18. alter session set sql_trace=true


  19. call count cpu elapsed disk query current rows
  20. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  21. Parse 0 0.00 0.00 0 0 0 0
  22. Execute 1 0.00 0.00 0 0 0 0
  23. Fetch 0 0.00 0.00 0 0 0 0
  24. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  25. total 1 0.00 0.00 0 0 0 0

  26. Misses in library cache during parse: 0
  27. Misses in library cache during execute: 1
  28. Optimizer mode: ALL_ROWS
  29. Parsing user id: SYS
  30. ********************************************************************************

  31. SQL ID: 7cfz5wy9caaf4 Plan Hash: 4015672053

  32. SELECT NAME NAME_COL_PLUS_SHOW_PARAM,DECODE(TYPE,1,\'boolean\',2,\'string\',3,
  33.   \'integer\',4,\'file\',5,\'number\', 6,\'big integer\', \'unknown\') TYPE,
  34.   DISPLAY_VALUE VALUE_COL_PLUS_SHOW_PARAM
  35. FROM
  36.  V$PARAMETER WHERE UPPER(NAME) LIKE UPPER(:NMBIND_SHOW_OBJ) ORDER BY
  37.   NAME_COL_PLUS_SHOW_PARAM,ROWNUM


  38. call count cpu elapsed disk query current rows
  39. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  40. Parse 1 0.00 0.00 0 0 0 0
  41. Execute 1 0.00 0.00 0 0 0 0
  42. Fetch 2 0.00 0.00 0 0 0 1
  43. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  44. total 4 0.01 0.01 0 0 0 1

  45. Misses in library cache during parse: 1
  46. Misses in library cache during execute: 1
  47. Optimizer mode: ALL_ROWS
  48. Parsing user id: SYS
  49. Number of plan statistics captured: 1

  50. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  51. ---------- ---------- ---------- ---------------------------------------------------
  52.          1 1 1 SORT ORDER BY (cr=0 pr=0 pw=0 time=9094 us cost=2 size=2128 card=1)
  53.          1 1 1 COUNT (cr=0 pr=0 pw=0 time=8984 us)
  54.          1 1 1 HASH JOIN (cr=0 pr=0 pw=0 time=8979 us cost=1 size=2128 card=1)
  55.          1 1 1 FIXED TABLE FULL X$KSPPI (cr=0 pr=0 pw=0 time=6028 us cost=0 size=94 card=1)
  56.       2752 2752 2752 FIXED TABLE FULL X$KSPPCV (cr=0 pr=0 pw=0 time=3134 us cost=0 size=203400 card=100)

  57. ********************************************************************************

  58. SQL ID: asvzxj61dc5vs Plan Hash: 3028786551

  59. select timestamp, flags
  60. from
  61.  fixed_obj$ where obj#=:1


  62. call count cpu elapsed disk query current rows
  63. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  64. Parse 1 0.00 0.00 0 0 0 0
  65. Execute 1 0.00 0.00 0 0 0 0
  66. Fetch 1 0.00 0.00 0 2 0 0
  67. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  68. total 3 0.00 0.00 0 2 0 0

  69. Misses in library cache during parse: 1
  70. Misses in library cache during execute: 1
  71. Optimizer mode: CHOOSE
  72. Parsing user id: SYS (recursive depth: 1)
  73. Number of plan statistics captured: 1

  74. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  75. ---------- ---------- ---------- ---------------------------------------------------
  76.          0 0 0 TABLE ACCESS BY INDEX ROWID FIXED_OBJ$ (cr=2 pr=0 pw=0 time=15 us cost=2 size=17 card=1)
  77.          0 0 0 INDEX UNIQUE SCAN I_FIXED_OBJ$_OBJ# (cr=2 pr=0 pw=0 time=10 us cost=1 size=0 card=1)(object id 102)

  78. ********************************************************************************

  79. SQL ID: 96g93hntrzjtr Plan Hash: 2239883476

  80. select /*+ rule */ bucket_cnt, row_cnt, cache_cnt, null_cnt, timestamp#,
  81.   sample_size, minimum, maximum, distcnt, lowval, hival, density, col#,
  82.   spare1, spare2, avgcln
  83. from
  84.  hist_head$ where obj#=:1 and intcol#=:2


  85. call count cpu elapsed disk query current rows
  86. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  87. Parse 1 0.00 0.00 0 0 0 0
  88. Execute 20 0.00 0.00 0 0 0 0
  89. Fetch 20 0.00 0.00 0 58 0 18
  90. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  91. total 41 0.00 0.00 0 58 0 18

  92. Misses in library cache during parse: 1
  93. Misses in library cache during execute: 1
  94. Optimizer mode: RULE
  95. Parsing user id: SYS (recursive depth: 2)
  96. Number of plan statistics captured: 1

  97. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  98. ---------- ---------- ---------- ---------------------------------------------------
  99.          1 1 1 TABLE ACCESS BY INDEX ROWID HIST_HEAD$ (cr=3 pr=0 pw=0 time=206 us)
  100.          1 1 1 INDEX RANGE SCAN I_HH_OBJ#_INTCOL# (cr=2 pr=0 pw=0 time=159 us)(object id 427)

  101. ********************************************************************************

  102. SQL ID: db78fxqxwxt7r Plan Hash: 3312420081

  103. select /*+ rule */ bucket, endpoint, col#, epvalue
  104. from
  105.  histgrm$ where obj#=:1 and intcol#=:2 and row#=:3 order by bucket


  106. call count cpu elapsed disk query current rows
  107. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  108. Parse 1 0.00 0.00 0 0 0 0
  109. Execute 2 0.00 0.00 0 0 0 0
  110. Fetch 2 0.00 0.00 0 6 0 3
  111. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  112. total 5 0.00 0.00 0 6 0 3

  113. Misses in library cache during parse: 1
  114. Misses in library cache during execute: 1
  115. Optimizer mode: RULE
  116. Parsing user id: SYS (recursive depth: 2)
  117. Number of plan statistics captured: 1

  118. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  119. ---------- ---------- ---------- ---------------------------------------------------
  120.          1 1 1 SORT ORDER BY (cr=3 pr=0 pw=0 time=182 us cost=0 size=0 card=0)
  121.          1 1 1 TABLE ACCESS CLUSTER HISTGRM$ (cr=3 pr=0 pw=0 time=150 us)
  122.          1 1 1 INDEX UNIQUE SCAN I_OBJ#_INTCOL# (cr=2 pr=0 pw=0 time=102 us)(object id 422)

  123. ********************************************************************************

  124. SQL ID: gcnf7vvsyq6w3 Plan Hash: 0

  125. select SADDR , SID , SERIAL# , AUDSID , PADDR , USER# , USERNAME , COMMAND ,
  126.   OWNERID, TADDR , LOCKWAIT , STATUS , SERVER , SCHEMA# , SCHEMANAME ,OSUSER ,
  127.    PROCESS , MACHINE , PORT , TERMINAL , PROGRAM , TYPE , SQL_ADDRESS ,
  128.   SQL_HASH_VALUE, SQL_ID, SQL_CHILD_NUMBER , SQL_EXEC_START, SQL_EXEC_ID,
  129.   PREV_SQL_ADDR , PREV_HASH_VALUE , PREV_SQL_ID, PREV_CHILD_NUMBER ,
  130.   PREV_EXEC_START , PREV_EXEC_ID , PLSQL_ENTRY_OBJECT_ID,
  131.   PLSQL_ENTRY_SUBPROGRAM_ID, PLSQL_OBJECT_ID, PLSQL_SUBPROGRAM_ID, MODULE ,
  132.   MODULE_HASH , ACTION , ACTION_HASH , CLIENT_INFO , FIXED_TABLE_SEQUENCE ,
  133.   ROW_WAIT_OBJ# , ROW_WAIT_FILE# , ROW_WAIT_BLOCK# , ROW_WAIT_ROW# ,
  134.   TOP_LEVEL_CALL#, LOGON_TIME , LAST_CALL_ET , PDML_ENABLED , FAILOVER_TYPE
  135.   , FAILOVER_METHOD , FAILED_OVER, RESOURCE_CONSUMER_GROUP, PDML_STATUS,
  136.   PDDL_STATUS, PQ_STATUS, CURRENT_QUEUE_DURATION, CLIENT_IDENTIFIER,
  137.   BLOCKING_SESSION_STATUS, BLOCKING_INSTANCE, BLOCKING_SESSION,
  138.   FINAL_BLOCKING_SESSION_STATUS, FINAL_BLOCKING_INSTANCE,
  139.   FINAL_BLOCKING_SESSION, SEQ#, EVENT#,EVENT,P1TEXT,P1,P1RAW,P2TEXT,P2,P2RAW,
  140.   P3TEXT,P3,P3RAW,WAIT_CLASS_ID, WAIT_CLASS#,WAIT_CLASS,WAIT_TIME,
  141.   SECONDS_IN_WAIT,STATE,WAIT_TIME_MICRO,TIME_REMAINING_MICRO,
  142.   TIME_SINCE_LAST_WAIT_MICRO,SERVICE_NAME, SQL_TRACE, SQL_TRACE_WAITS,
  143.   SQL_TRACE_BINDS, SQL_TRACE_PLAN_STATS, SESSION_EDITION_ID, CREATOR_ADDR,
  144.   CREATOR_SERIAL#, ECID
  145. from
  146.  GV$SESSION where inst_id = USERENV(\'Instance\')


  147. call count cpu elapsed disk query current rows
  148. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  149. Parse 1 0.01 0.01 0 0 0 0
  150. Execute 0 0.00 0.00 0 0 0 0
  151. Fetch 0 0.00 0.00 0 0 0 0
  152. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  153. total 1 0.01 0.01 0 0 0 0

  154. Misses in library cache during parse: 1
  155. Optimizer mode: CHOOSE
  156. Parsing user id: SYS (recursive depth: 1)
  157. ********************************************************************************

  158. SQL ID: gzp9y42kcbx6m Plan Hash: 644658511

  159. select sid,serial#,username
  160. from
  161.  v$session where username=\'SCOTT\'


  162. call count cpu elapsed disk query current rows
  163. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  164. Parse 1 0.00 0.00 0 0 0 0
  165. Execute 1 0.00 0.00 0 0 0 0
  166. Fetch 2 0.00 0.00 0 0 0 1
  167. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  168. total 4 0.00 0.00 0 0 0 1

  169. Misses in library cache during parse: 1
  170. Optimizer mode: ALL_ROWS
  171. Parsing user id: SYS
  172. Number of plan statistics captured: 1

  173. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  174. ---------- ---------- ---------- ---------------------------------------------------
  175.          1 1 1 NESTED LOOPS (cr=0 pr=0 pw=0 time=231 us cost=0 size=121 card=1)
  176.          1 1 1 NESTED LOOPS (cr=0 pr=0 pw=0 time=2330 us cost=0 size=108 card=1)
  177.          1 1 1 FIXED TABLE FULL X$KSUSE (cr=0 pr=0 pw=0 time=1981 us cost=0 size=82 card=1)
  178.          1 1 1 FIXED TABLE FIXED INDEX X$KSLWT (ind:1) (cr=0 pr=0 pw=0 time=339 us cost=0 size=26 card=1)
  179.          1 1 1 FIXED TABLE FIXED INDEX X$KSLED (ind:2) (cr=0 pr=0 pw=0 time=2 us cost=0 size=13 card=1)

  180. ********************************************************************************

  181. SQL ID: 3nkd3g3ju5ph1 Plan Hash: 2853959010

  182. select obj#,type#,ctime,mtime,stime, status, dataobj#, flags, oid$, spare1,
  183.   spare2
  184. from
  185.  obj$ where owner#=:1 and name=:2 and namespace=:3 and remoteowner is null
  186.   and linkname is null and subname is null


  187. call count cpu elapsed disk query current rows
  188. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  189. Parse 1 0.00 0.00 0 0 0 0
  190. Execute 4 0.00 0.00 0 0 0 0
  191. Fetch 4 0.00 0.00 0 16 0 4
  192. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  193. total 9 0.00 0.00 0 16 0 4

  194. Misses in library cache during parse: 1
  195. Misses in library cache during execute: 1
  196. Optimizer mode: CHOOSE
  197. Parsing user id: SYS (recursive depth: 1)
  198. Number of plan statistics captured: 1

  199. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  200. ---------- ---------- ---------- ---------------------------------------------------
  201.          1 1 1 TABLE ACCESS BY INDEX ROWID OBJ$ (cr=4 pr=0 pw=0 time=145 us cost=4 size=82 card=1)
  202.          1 1 1 INDEX RANGE SCAN I_OBJ2 (cr=3 pr=0 pw=0 time=109 us cost=3 size=0 card=1)(object id 37)

  203. ********************************************************************************

  204. SQL ID: 7ng34ruy5awxq Plan Hash: 2542797530

  205. select i.obj#,i.ts#,i.file#,i.block#,i.intcols,i.type#,i.flags,i.property,
  206.   i.pctfree$,i.initrans,i.maxtrans,i.blevel,i.leafcnt,i.distkey,i.lblkkey,
  207.   i.dblkkey,i.clufac,i.cols,i.analyzetime,i.samplesize,i.dataobj#,
  208.   nvl(i.degree,1),nvl(i.instances,1),i.rowcnt,mod(i.pctthres$,256),
  209.   i.indmethod#,i.trunccnt,nvl(c.unicols,0),nvl(c.deferrable#+c.valid#,0),
  210.   nvl(i.spare1,i.intcols),i.spare4,i.spare2,i.spare6,decode(i.pctthres$,null,
  211.   null,mod(trunc(i.pctthres$/256),256)),ist.cachedblk,ist.cachehit,
  212.   ist.logicalread
  213. from
  214.  ind$ i, ind_stats$ ist, (select enabled, min(cols) unicols,
  215.   min(to_number(bitand(defer,1))) deferrable#,min(to_number(bitand(defer,4)))
  216.   valid# from cdef$ where obj#=:1 and enabled > 1 group by enabled) c where
  217.   i.obj#=c.enabled(+) and i.obj# = ist.obj#(+) and i.bo#=:1 order by i.obj#


  218. call count cpu elapsed disk query current rows
  219. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  220. Parse 1 0.00 0.00 0 0 0 0
  221. Execute 5 0.00 0.00 0 0 0 0
  222. Fetch 10 0.00 0.00 0 36 0 5
  223. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  224. total 16 0.00 0.00 0 36 0 5

  225. Misses in library cache during parse: 1
  226. Misses in library cache during execute: 1
  227. Optimizer mode: CHOOSE
  228. Parsing user id: SYS (recursive depth: 2)
  229. Number of plan statistics captured: 1

  230. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  231. ---------- ---------- ---------- ---------------------------------------------------
  232.          1 1 1 SORT ORDER BY (cr=8 pr=0 pw=0 time=644 us cost=7 size=372 card=2)
  233.          1 1 1 HASH JOIN OUTER (cr=8 pr=0 pw=0 time=608 us cost=6 size=372 card=2)
  234.          1 1 1 NESTED LOOPS OUTER (cr=5 pr=0 pw=0 time=177 us cost=2 size=286 card=2)
  235.          1 1 1 TABLE ACCESS CLUSTER IND$ (cr=4 pr=0 pw=0 time=100 us cost=2 size=182 card=2)
  236.          1 1 1 INDEX UNIQUE SCAN I_OBJ# (cr=2 pr=0 pw=0 time=38 us cost=1 size=0 card=1)(object id 3)
  237.          0 0 0 TABLE ACCESS BY INDEX ROWID IND_STATS$ (cr=1 pr=0 pw=0 time=71 us cost=0 size=52 card=1)
  238.          0 0 0 INDEX UNIQUE SCAN I_IND_STATS$_OBJ# (cr=1 pr=0 pw=0 time=66 us cost=0 size=0 card=1)(object id 433)
  239.          0 0 0 VIEW (cr=3 pr=0 pw=0 time=202 us cost=3 size=43 card=1)
  240.          0 0 0 SORT GROUP BY (cr=3 pr=0 pw=0 time=200 us cost=3 size=15 card=1)
  241.          0 0 0 TABLE ACCESS CLUSTER CDEF$ (cr=3 pr=0 pw=0 time=149 us cost=2 size=15 card=1)
  242.          1 1 1 INDEX UNIQUE SCAN I_COBJ# (cr=2 pr=0 pw=0 time=43 us cost=1 size=0 card=1)(object id 30)

  243. ********************************************************************************

  244. SQL ID: 5n1fs4m2n2y0r Plan Hash: 299250003

  245. select pos#,intcol#,col#,spare1,bo#,spare2,spare3
  246. from
  247.  icol$ where obj#=:1


  248. call count cpu elapsed disk query current rows
  249. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  250. Parse 1 0.00 0.00 0 0 0 0
  251. Execute 5 0.00 0.00 0 0 0 0
  252. Fetch 20 0.00 0.00 0 40 0 15
  253. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  254. total 26 0.00 0.00 0 40 0 15

  255. Misses in library cache during parse: 1
  256. Misses in library cache during execute: 1
  257. Optimizer mode: CHOOSE
  258. Parsing user id: SYS (recursive depth: 2)
  259. Number of plan statistics captured: 1

  260. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  261. ---------- ---------- ---------- ---------------------------------------------------
  262.          1 1 1 TABLE ACCESS BY INDEX ROWID ICOL$ (cr=4 pr=0 pw=0 time=52 us cost=2 size=54 card=2)
  263.          1 1 1 INDEX RANGE SCAN I_ICOL1 (cr=3 pr=0 pw=0 time=48 us cost=1 size=0 card=2)(object id 42)

  264. ********************************************************************************

  265. SQL ID: 83taa7kaw59c1 Plan Hash: 3765558045

  266. select name,intcol#,segcol#,type#,length,nvl(precision#,0),decode(type#,2,
  267.   nvl(scale,-127/*MAXSB1MINAL*/),178,scale,179,scale,180,scale,181,scale,182,
  268.   scale,183,scale,231,scale,0),null$,fixedstorage,nvl(deflength,0),default$,
  269.   rowid,col#,property, nvl(charsetid,0),nvl(charsetform,0),spare1,spare2,
  270.   nvl(spare3,0)
  271. from
  272.  col$ where obj#=:1 order by intcol#


  273. call count cpu elapsed disk query current rows
  274. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  275. Parse 1 0.00 0.00 0 0 0 0
  276. Execute 5 0.00 0.00 0 0 0 0
  277. Fetch 31 0.00 0.00 0 16 0 26
  278. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  279. total 37 0.00 0.00 0 16 0 26

  280. Misses in library cache during parse: 1
  281. Misses in library cache during execute: 1
  282. Optimizer mode: CHOOSE
  283. Parsing user id: SYS (recursive depth: 2)
  284. Number of plan statistics captured: 1

  285. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  286. ---------- ---------- ---------- ---------------------------------------------------
  287.          4 4 4 SORT ORDER BY (cr=4 pr=0 pw=0 time=54 us cost=3 size=708 card=12)
  288.          4 4 4 TABLE ACCESS CLUSTER COL$ (cr=4 pr=0 pw=0 time=27 us cost=2 size=708 card=12)
  289.          1 1 1 INDEX UNIQUE SCAN I_OBJ# (cr=2 pr=0 pw=0 time=9 us cost=1 size=0 card=1)(object id 3)

  290. ********************************************************************************

  291. SQL ID: 3ktacv9r56b51 Plan Hash: 4184428695

  292. select owner#,name,namespace,remoteowner,linkname,p_timestamp,p_obj#,
  293.   nvl(property,0),subname,type#,d_attrs
  294. from
  295.  dependency$ d, obj$ o where d_obj#=:1 and p_obj#=obj#(+) order by order#


  296. call count cpu elapsed disk query current rows
  297. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  298. Parse 2 0.00 0.00 0 0 0 0
  299. Execute 2 0.00 0.00 0 0 0 0
  300. Fetch 12 0.00 0.00 0 27 0 10
  301. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  302. total 16 0.00 0.00 0 27 0 10

  303. Misses in library cache during parse: 1
  304. Misses in library cache during execute: 1
  305. Optimizer mode: CHOOSE
  306. Parsing user id: SYS (recursive depth: 1)
  307. Number of plan statistics captured: 2

  308. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  309. ---------- ---------- ---------- ---------------------------------------------------
  310.          1 5 9 SORT ORDER BY (cr=14 pr=0 pw=0 time=304 us cost=11 size=330 card=3)
  311.          1 5 9 NESTED LOOPS OUTER (cr=14 pr=0 pw=0 time=297 us cost=10 size=330 card=3)
  312.          1 5 9 TABLE ACCESS BY INDEX ROWID DEPENDENCY$ (cr=4 pr=0 pw=0 time=80 us cost=4 size=84 card=3)
  313.          1 5 9 INDEX RANGE SCAN I_DEPENDENCY1 (cr=3 pr=0 pw=0 time=51 us cost=3 size=0 card=3)(object id 106)
  314.          1 3 5 TABLE ACCESS BY INDEX ROWID OBJ$ (cr=10 pr=0 pw=0 time=157 us cost=2 size=82 card=1)
  315.          1 3 5 INDEX RANGE SCAN I_OBJ1 (cr=6 pr=0 pw=0 time=97 us cost=1 size=0 card=1)(object id 36)

  316. ********************************************************************************

  317. SQL ID: 87gaftwrm2h68 Plan Hash: 1218588913

  318. select o.owner#,o.name,o.namespace,o.remoteowner,o.linkname,o.subname
  319. from
  320.  obj$ o where o.obj#=:1


  321. call count cpu elapsed disk query current rows
  322. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  323. Parse 1 0.00 0.00 0 0 0 0
  324. Execute 1 0.00 0.00 0 0 0 0
  325. Fetch 1 0.00 0.00 0 3 0 1
  326. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  327. total 3 0.00 0.00 0 3 0 1

  328. Misses in library cache during parse: 1
  329. Misses in library cache during execute: 1
  330. Optimizer mode: CHOOSE
  331. Parsing user id: SYS (recursive depth: 2)
  332. Number of plan statistics captured: 1

  333. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  334. ---------- ---------- ---------- ---------------------------------------------------
  335.          1 1 1 TABLE ACCESS BY INDEX ROWID OBJ$ (cr=3 pr=0 pw=0 time=38 us cost=3 size=82 card=1)
  336.          1 1 1 INDEX RANGE SCAN I_OBJ1 (cr=2 pr=0 pw=0 time=31 us cost=2 size=0 card=1)(object id 36)

  337. ********************************************************************************

  338. SQL ID: ga9j9xk5cy9s0 Plan Hash: 1697022209

  339. select /*+ index(idl_sb4$ i_idl_sb41) +*/ piece#,length,piece
  340. from
  341.  idl_sb4$ where obj#=:1 and part=:2 and version=:3 order by piece#


  342. call count cpu elapsed disk query current rows
  343. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  344. Parse 3 0.00 0.00 0 0 0 0
  345. Execute 3 0.00 0.00 0 0 0 0
  346. Fetch 7 0.00 0.00 1 18 0 4
  347. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  348. total 13 0.00 0.00 1 18 0 4

  349. Misses in library cache during parse: 1
  350. Misses in library cache during execute: 1
  351. Optimizer mode: CHOOSE
  352. Parsing user id: SYS (recursive depth: 1)
  353. Number of plan statistics captured: 3

  354. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  355. ---------- ---------- ---------- ---------------------------------------------------
  356.          2 1 2 TABLE ACCESS BY INDEX ROWID IDL_SB4$ (cr=5 pr=0 pw=0 time=205 us cost=3 size=19 card=1)
  357.          2 1 2 INDEX RANGE SCAN I_IDL_SB41 (cr=3 pr=0 pw=0 time=36 us cost=2 size=0 card=1)(object id 239)

  358. ********************************************************************************

  359. SQL ID: cvn54b7yz0s8u Plan Hash: 3246118364

  360. select /*+ index(idl_ub1$ i_idl_ub11) +*/ piece#,length,piece
  361. from
  362.  idl_ub1$ where obj#=:1 and part=:2 and version=:3 order by piece#


  363. call count cpu elapsed disk query current rows
  364. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  365. Parse 3 0.00 0.00 0 0 0 0
  366. Execute 3 0.00 0.00 0 0 0 0
  367. Fetch 6 0.00 0.00 3 20 0 5
  368. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  369. total 12 0.00 0.00 3 20 0 5

  370. Misses in library cache during parse: 1
  371. Misses in library cache during execute: 1
  372. Optimizer mode: CHOOSE
  373. Parsing user id: SYS (recursive depth: 1)
  374. Number of plan statistics captured: 3

  375. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  376. ---------- ---------- ---------- ---------------------------------------------------
  377.          1 2 2 TABLE ACCESS BY INDEX ROWID IDL_UB1$ (cr=5 pr=1 pw=0 time=160 us cost=3 size=44 card=2)
  378.          1 2 2 INDEX RANGE SCAN I_IDL_UB11 (cr=3 pr=0 pw=0 time=30 us cost=2 size=0 card=2)(object id 236)

  379. ********************************************************************************

  380. SQL ID: c6awqs517jpj0 Plan Hash: 1319326155

  381. select /*+ index(idl_char$ i_idl_char1) +*/ piece#,length,piece
  382. from
  383.  idl_char$ where obj#=:1 and part=:2 and version=:3 order by piece#


  384. call count cpu elapsed disk query current rows
  385. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  386. Parse 3 0.00 0.00 0 0 0 0
  387. Execute 3 0.00 0.00 0 0 0 0
  388. Fetch 4 0.00 0.01 1 9 0 1
  389. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  390. total 10 0.00 0.01 1 9 0 1

  391. Misses in library cache during parse: 1
  392. Misses in library cache during execute: 1
  393. Optimizer mode: CHOOSE
  394. Parsing user id: SYS (recursive depth: 1)
  395. Number of plan statistics captured: 3

  396. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  397. ---------- ---------- ---------- ---------------------------------------------------
  398.          1 0 1 TABLE ACCESS BY INDEX ROWID IDL_CHAR$ (cr=3 pr=0 pw=0 time=3509 us cost=3 size=21 card=1)
  399.          1 0 1 INDEX RANGE SCAN I_IDL_CHAR1 (cr=2 pr=0 pw=0 time=30 us cost=2 size=0 card=1)(object id 237)

  400. ********************************************************************************

  401. SQL ID: 39m4sx9k63ba2 Plan Hash: 2317816222

  402. select /*+ index(idl_ub2$ i_idl_ub21) +*/ piece#,length,piece
  403. from
  404.  idl_ub2$ where obj#=:1 and part=:2 and version=:3 order by piece#


  405. call count cpu elapsed disk query current rows
  406. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  407. Parse 3 0.00 0.00 0 0 0 0
  408. Execute 3 0.00 0.00 0 0 0 0
  409. Fetch 4 0.00 0.00 1 11 0 2
  410. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  411. total 10 0.00 0.01 1 11 0 2

  412. Misses in library cache during parse: 1
  413. Misses in library cache during execute: 1
  414. Optimizer mode: CHOOSE
  415. Parsing user id: SYS (recursive depth: 1)
  416. Number of plan statistics captured: 3

  417. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  418. ---------- ---------- ---------- ---------------------------------------------------
  419.          2 1 2 TABLE ACCESS BY INDEX ROWID IDL_UB2$ (cr=3 pr=0 pw=0 time=2460 us cost=3 size=40 card=2)
  420.          2 1 2 INDEX RANGE SCAN I_IDL_UB21 (cr=2 pr=0 pw=0 time=29 us cost=2 size=0 card=2)(object id 238)

  421. ********************************************************************************

  422. SQL ID: 83sp8xb9ytgkv Plan Hash: 0

  423. BEGIN dbms_system.set_ev(21,2615,10046,12,\'SCOTT\'); END;


  424. call count cpu elapsed disk query current rows
  425. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  426. Parse 1 0.00 0.00 0 0 0 0
  427. Execute 1 0.00 0.00 0 0 0 1
  428. Fetch 0 0.00 0.00 0 0 0 0
  429. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  430. total 2 0.00 0.00 0 0 0 1

  431. Misses in library cache during parse: 1
  432. Optimizer mode: ALL_ROWS
  433. Parsing user id: SYS
  434. ********************************************************************************

  435. SQL ID: b1wc53ddd6h3p Plan Hash: 1637390370

  436. select audit$,options
  437. from
  438.  procedure$ where obj#=:1


  439. call count cpu elapsed disk query current rows
  440. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  441. Parse 2 0.00 0.00 0 0 0 0
  442. Execute 2 0.00 0.00 0 0 0 0
  443. Fetch 2 0.00 0.00 0 6 0 2
  444. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  445. total 6 0.00 0.00 0 6 0 2

  446. Misses in library cache during parse: 1
  447. Misses in library cache during execute: 1
  448. Optimizer mode: CHOOSE
  449. Parsing user id: SYS (recursive depth: 1)
  450. Number of plan statistics captured: 2

  451. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  452. ---------- ---------- ---------- ---------------------------------------------------
  453.          1 1 1 TABLE ACCESS BY INDEX ROWID PROCEDURE$ (cr=3 pr=0 pw=0 time=46 us cost=2 size=47 card=1)
  454.          1 1 1 INDEX UNIQUE SCAN I_PROCEDURE1 (cr=2 pr=0 pw=0 time=26 us cost=1 size=0 card=1)(object id 231)

  455. ********************************************************************************

  456. SQL ID: 8swypbbr0m372 Plan Hash: 893970548

  457. select order#,columns,types
  458. from
  459.  access$ where d_obj#=:1


  460. call count cpu elapsed disk query current rows
  461. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  462. Parse 2 0.00 0.00 0 0 0 0
  463. Execute 2 0.00 0.00 0 0 0 0
  464. Fetch 9 0.00 0.00 0 18 0 7
  465. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  466. total 13 0.00 0.00 0 18 0 7

  467. Misses in library cache during parse: 1
  468. Misses in library cache during execute: 1
  469. Optimizer mode: CHOOSE
  470. Parsing user id: SYS (recursive depth: 1)
  471. Number of plan statistics captured: 2

  472. Rows (1st) Rows (avg) Rows (max) Row Source Operation
  473. ---------- ---------- ---------- ---------------------------------------------------
  474.          7 4 7 TABLE ACCESS BY INDEX ROWID ACCESS$ (cr=9 pr=0 pw=0 time=56 us cost=3 size=161 card=7)
  475.          7 4 7 INDEX RANGE SCAN I_ACCESS1 (cr=6 pr=0 pw=0 time=48 us cost=2 size=0 card=7)(object id 108)




  476. ********************************************************************************

  477. OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS

  478. call count cpu elapsed disk query current rows
  479. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  480. Parse 3 0.00 0.00 0 0 0 0
  481. Execute 4 0.01 0.01 0 0 0 1
  482. Fetch 4 0.01 0.01 0 0 0 2
  483. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  484. total 11 0.02 0.03 0 0 0 3

  485. Misses in library cache during parse: 3
  486. Misses in library cache during execute: 2


  487. OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS

  488. call count cpu elapsed disk query current rows
  489. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  490. Parse 27 0.03 0.03 0 0 0 0
  491. Execute 61 0.01 0.02 0 0 0 0
  492. Fetch 133 0.01 0.02 6 286 0 103
  493. ------- ------ -------- ---------- ---------- ---------- ---------- ----------
  494. total 221 0.06 0.08 6 286 0 103

  495. Misses in library cache during parse: 16
  496. Misses in library cache during execute: 15

  497.     4 user SQL statements in session.
  498.    27 internal SQL statements in session.
  499.    31 SQL statements in session.
  500. ********************************************************************************
  501. Trace file: HOEGH_ora_16427.trc
  502. Trace file compatibility: 11.1.0.7
  503. Sort options: default

  504.        1 session in tracefile.
  505.        4 user SQL statements in trace file.
  506.       27 internal SQL statements in trace file.
  507.       31 SQL statements in trace file.
  508.       20 unique SQL statements in trace file.
  509.      534 lines in trace file.
  510.      337 elapsed seconds in trace file.


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28389881/viewspace-1745592/,如需轉載,請註明出處,否則將追究法律責任。

相關文章