如何使用SQL_TRACE和10046事件
Eygle大師的微信講堂昨天開課,第一堂課和大家分享了一些學習Oracle的基本方法,其中提到了使用SQL_TRACE和10046事件。SQL_TRACE是Oracle提供的用於進行SQL跟蹤的手段,是強有力的輔助診斷工具。在日常的資料庫問題診斷和解決中,SQL_TRACE是非常常用的方法。
對於這個工具,我很早就聽過,但是從來就沒用過,“紙上得來終覺淺,絕知此事要躬行”,操練起來。
1.環境準備
我們在Oracle11g中進行測試。
點選(此處)摺疊或開啟
-
SQL>
-
SQL> select * from v$version;
-
-
BANNER
-
--------------------------------------------------------------------------------
-
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
-
PL/SQL Release 11.2.0.3.0 - Production
-
CORE 11.2.0.3.0 Production
-
TNS for Linux: Version 11.2.0.3.0 - Production
-
NLSRTL Version 11.2.0.3.0 - Production
-
- 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,如下所示。
點選(此處)摺疊或開啟
-
SQL>
-
SQL> show parameter SQL_TRACE
-
-
NAME TYPE VALUE
-
------------------------------------ ----------- ------------------------------
-
SQL_TRACE boolean FALSE
-
SQL>
-
SQL> alter session set SQL_TRACE=true;
-
-
Session altered.
-
-
SQL>
-
SQL> show parameter SQL_TRACE
-
-
NAME TYPE VALUE
-
------------------------------------ ----------- ------------------------------
-
SQL_TRACE boolean TRUE
- SQL>
3.連線soctt使用者,執行查詢語句
登陸scott使用者,執行兩條簡單的查詢語句。點選(此處)摺疊或開啟
-
[oracle@hoegh admin]$ sqlplus scott/tiger
-
-
SQL*Plus: Release 11.2.0.3.0 Production on Wed May 27 09:59:48 2015
-
-
Copyright (c) 1982, 2011, Oracle. All rights reserved.
-
-
-
Connected to:
-
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
-
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-
-
SQL> select * from cat;
-
-
TABLE_NAME TABLE_TYPE
-
------------------------------ -----------
-
BONUS TABLE
-
DEPT TABLE
-
EMP TABLE
-
SALGRADE TABLE
-
-
SQL> select * from dept;
-
-
DEPTNO DNAME LOC
-
---------- -------------- -------------
-
10 ACCOUNTING NEW YORK
-
20 RESEARCH DALLAS
-
30 SALES CHICAGO
- 40 OPERATIONS BOSTON
4.生成trace檔案
plustrace角色
點選(此處)摺疊或開啟
-
SQL>
-
SQL> show user
-
USER is \"SCOTT\"
-
SQL>
-
SQL> set autotrace on
-
SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled
-
SP2-0611: Error enabling STATISTICS report
- SQL>
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過程來實現對程式的跟蹤。
點選(此處)摺疊或開啟
-
SQL>
-
SQL> select sid,serial#,username from v$session where username=\'SCOTT\';
-
-
SID SERIAL# USERNAME
-
---------- ---------- ------------------------------
-
21 2615 SCOTT
-
-
SQL>
-
SQL> exec dbms_system.set_ev(21,2615,10046,12,\'SCOTT\');
-
-
PL/SQL procedure successfully completed.
-
- SQL>
5.檢視trace檔案
存放目錄
點選(此處)摺疊或開啟
-
SQL> show parameter diagnostic_dest
-
-
NAME TYPE VALUE
-
------------------------------------ ----------- ------------------------------
-
diagnostic_dest string /u01/app/oracle
- SQL>
檢視trace檔案
tracefile 命名規則 :點選(此處)摺疊或開啟
-
[oracle@hoegh trace]$ more HOEGH_ora_16427.trc
-
Trace file /u01/app/oracle/diag/rdbms/hoegh/HOEGH/trace/HOEGH_ora_16427.trc
-
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
-
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-
ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1
-
System name: Linux
-
Node name: hoegh.example.com
-
Release: 2.6.18-164.el5PAE
-
Version: #1 SMP Thu Sep 3 02:28:20 EDT 2009
-
Machine: i686
-
VM name: VMWare Version: 6
-
Instance name: HOEGH
-
Redo thread mounted by this instance: 1
-
Oracle process number: 23
-
Unix process pid: 16427, image: oracle@hoegh.example.com (TNS V1-V3)
-
-
-
*** 2015-05-27 09:56:36.240
-
*** SESSION ID:(142.1705) 2015-05-27 09:56:36.240
-
*** CLIENT ID:() 2015-05-27 09:56:36.240
-
*** SERVICE NAME:(SYS$USERS) 2015-05-27 09:56:36.240
-
*** MODULE NAME:(sqlplus@hoegh.example.com (TNS V1-V3)) 2015-05-27 09:56:36.2
-
40
-
*** ACTION NAME:() 2015-05-27 09:56:36.240
格式化trace檔案
點選(此處)摺疊或開啟
-
[oracle@hoegh trace]$ tkprof HOEGH_ora_16427.trc 10046.txt
-
-
TKPROF: Release 11.2.0.3.0 - Development on Wed May 27 11:20:36 2015
-
-
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
-
-
- [oracle@hoegh trace]$
檢視格式化後的trace報告
點選(此處)摺疊或開啟
-
[oracle@hoegh trace]$ more 10046.txt
-
-
TKPROF: Release 11.2.0.3.0 - Development on Wed May 27 11:20:36 2015
-
-
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
-
-
-
[oracle@ hoegh trace]$
-
-
-
-
TKPROF: Release 11.2.0.3.0 - Development on Wed May 27 10:06:10 2015
-
-
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
-
-
Trace file: HOEGH_ora_16427.trc
-
Sort options: default
-
-
********************************************************************************
-
count = number of times OCI procedure was executed
-
cpu = cpu time in seconds executing
-
elapsed = elapsed time in seconds executing
-
disk = number of physical reads of buffers from disk
-
query = number of buffers gotten for consistent read
-
current = number of buffers gotten in current mode (usually for update)
-
rows = number of rows processed by the fetch or execute call
-
********************************************************************************
-
-
SQL ID: 4tk6t8tfsfqbf Plan Hash: 0
-
-
alter session set sql_trace=true
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 0 0.00 0.00 0 0 0 0
-
Execute 1 0.00 0.00 0 0 0 0
-
Fetch 0 0.00 0.00 0 0 0 0
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
- total 1 0.00 0.00 0 0 0 0
大師論點
Eygle在課堂上提到他在面試時經常問的一個問題,“在什麼技術上你做過深入思考得到了自己的觀點”,絕大多數人的回答都是NO。Eygle提倡由點及面、由淺入深的學習方法,確實,不深入是不可能有收穫的。
期待下一次eygle在微信講堂的精彩分享。
附完整trace報告
點選(此處)摺疊或開啟
-
TKPROF: Release 11.2.0.3.0 - Development on Wed May 27 11:20:36 2015
-
-
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
-
-
-
[oracle@ hoegh trace]$
-
-
-
-
TKPROF: Release 11.2.0.3.0 - Development on Wed May 27 10:06:10 2015
-
-
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
-
-
Trace file: HOEGH_ora_16427.trc
-
Sort options: default
-
-
********************************************************************************
-
count = number of times OCI procedure was executed
-
cpu = cpu time in seconds executing
-
elapsed = elapsed time in seconds executing
-
disk = number of physical reads of buffers from disk
-
query = number of buffers gotten for consistent read
-
current = number of buffers gotten in current mode (usually for update)
-
rows = number of rows processed by the fetch or execute call
-
********************************************************************************
-
-
SQL ID: 4tk6t8tfsfqbf Plan Hash: 0
-
-
alter session set sql_trace=true
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 0 0.00 0.00 0 0 0 0
-
Execute 1 0.00 0.00 0 0 0 0
-
Fetch 0 0.00 0.00 0 0 0 0
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 1 0.00 0.00 0 0 0 0
-
-
Misses in library cache during parse: 0
-
Misses in library cache during execute: 1
-
Optimizer mode: ALL_ROWS
-
Parsing user id: SYS
-
********************************************************************************
-
-
SQL ID: 7cfz5wy9caaf4 Plan Hash: 4015672053
-
-
SELECT NAME NAME_COL_PLUS_SHOW_PARAM,DECODE(TYPE,1,\'boolean\',2,\'string\',3,
-
\'integer\',4,\'file\',5,\'number\', 6,\'big integer\', \'unknown\') TYPE,
-
DISPLAY_VALUE VALUE_COL_PLUS_SHOW_PARAM
-
FROM
-
V$PARAMETER WHERE UPPER(NAME) LIKE UPPER(:NMBIND_SHOW_OBJ) ORDER BY
-
NAME_COL_PLUS_SHOW_PARAM,ROWNUM
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 1 0.00 0.00 0 0 0 0
-
Execute 1 0.00 0.00 0 0 0 0
-
Fetch 2 0.00 0.00 0 0 0 1
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 4 0.01 0.01 0 0 0 1
-
-
Misses in library cache during parse: 1
-
Misses in library cache during execute: 1
-
Optimizer mode: ALL_ROWS
-
Parsing user id: SYS
-
Number of plan statistics captured: 1
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
1 1 1 SORT ORDER BY (cr=0 pr=0 pw=0 time=9094 us cost=2 size=2128 card=1)
-
1 1 1 COUNT (cr=0 pr=0 pw=0 time=8984 us)
-
1 1 1 HASH JOIN (cr=0 pr=0 pw=0 time=8979 us cost=1 size=2128 card=1)
-
1 1 1 FIXED TABLE FULL X$KSPPI (cr=0 pr=0 pw=0 time=6028 us cost=0 size=94 card=1)
-
2752 2752 2752 FIXED TABLE FULL X$KSPPCV (cr=0 pr=0 pw=0 time=3134 us cost=0 size=203400 card=100)
-
-
********************************************************************************
-
-
SQL ID: asvzxj61dc5vs Plan Hash: 3028786551
-
-
select timestamp, flags
-
from
-
fixed_obj$ where obj#=:1
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 1 0.00 0.00 0 0 0 0
-
Execute 1 0.00 0.00 0 0 0 0
-
Fetch 1 0.00 0.00 0 2 0 0
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 3 0.00 0.00 0 2 0 0
-
-
Misses in library cache during parse: 1
-
Misses in library cache during execute: 1
-
Optimizer mode: CHOOSE
-
Parsing user id: SYS (recursive depth: 1)
-
Number of plan statistics captured: 1
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
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)
-
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)
-
-
********************************************************************************
-
-
SQL ID: 96g93hntrzjtr Plan Hash: 2239883476
-
-
select /*+ rule */ bucket_cnt, row_cnt, cache_cnt, null_cnt, timestamp#,
-
sample_size, minimum, maximum, distcnt, lowval, hival, density, col#,
-
spare1, spare2, avgcln
-
from
-
hist_head$ where obj#=:1 and intcol#=:2
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 1 0.00 0.00 0 0 0 0
-
Execute 20 0.00 0.00 0 0 0 0
-
Fetch 20 0.00 0.00 0 58 0 18
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 41 0.00 0.00 0 58 0 18
-
-
Misses in library cache during parse: 1
-
Misses in library cache during execute: 1
-
Optimizer mode: RULE
-
Parsing user id: SYS (recursive depth: 2)
-
Number of plan statistics captured: 1
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
1 1 1 TABLE ACCESS BY INDEX ROWID HIST_HEAD$ (cr=3 pr=0 pw=0 time=206 us)
-
1 1 1 INDEX RANGE SCAN I_HH_OBJ#_INTCOL# (cr=2 pr=0 pw=0 time=159 us)(object id 427)
-
-
********************************************************************************
-
-
SQL ID: db78fxqxwxt7r Plan Hash: 3312420081
-
-
select /*+ rule */ bucket, endpoint, col#, epvalue
-
from
-
histgrm$ where obj#=:1 and intcol#=:2 and row#=:3 order by bucket
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 1 0.00 0.00 0 0 0 0
-
Execute 2 0.00 0.00 0 0 0 0
-
Fetch 2 0.00 0.00 0 6 0 3
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 5 0.00 0.00 0 6 0 3
-
-
Misses in library cache during parse: 1
-
Misses in library cache during execute: 1
-
Optimizer mode: RULE
-
Parsing user id: SYS (recursive depth: 2)
-
Number of plan statistics captured: 1
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
1 1 1 SORT ORDER BY (cr=3 pr=0 pw=0 time=182 us cost=0 size=0 card=0)
-
1 1 1 TABLE ACCESS CLUSTER HISTGRM$ (cr=3 pr=0 pw=0 time=150 us)
-
1 1 1 INDEX UNIQUE SCAN I_OBJ#_INTCOL# (cr=2 pr=0 pw=0 time=102 us)(object id 422)
-
-
********************************************************************************
-
-
SQL ID: gcnf7vvsyq6w3 Plan Hash: 0
-
-
select SADDR , SID , SERIAL# , AUDSID , PADDR , USER# , USERNAME , COMMAND ,
-
OWNERID, TADDR , LOCKWAIT , STATUS , SERVER , SCHEMA# , SCHEMANAME ,OSUSER ,
-
PROCESS , MACHINE , PORT , TERMINAL , PROGRAM , TYPE , SQL_ADDRESS ,
-
SQL_HASH_VALUE, SQL_ID, SQL_CHILD_NUMBER , SQL_EXEC_START, SQL_EXEC_ID,
-
PREV_SQL_ADDR , PREV_HASH_VALUE , PREV_SQL_ID, PREV_CHILD_NUMBER ,
-
PREV_EXEC_START , PREV_EXEC_ID , PLSQL_ENTRY_OBJECT_ID,
-
PLSQL_ENTRY_SUBPROGRAM_ID, PLSQL_OBJECT_ID, PLSQL_SUBPROGRAM_ID, MODULE ,
-
MODULE_HASH , ACTION , ACTION_HASH , CLIENT_INFO , FIXED_TABLE_SEQUENCE ,
-
ROW_WAIT_OBJ# , ROW_WAIT_FILE# , ROW_WAIT_BLOCK# , ROW_WAIT_ROW# ,
-
TOP_LEVEL_CALL#, LOGON_TIME , LAST_CALL_ET , PDML_ENABLED , FAILOVER_TYPE
-
, FAILOVER_METHOD , FAILED_OVER, RESOURCE_CONSUMER_GROUP, PDML_STATUS,
-
PDDL_STATUS, PQ_STATUS, CURRENT_QUEUE_DURATION, CLIENT_IDENTIFIER,
-
BLOCKING_SESSION_STATUS, BLOCKING_INSTANCE, BLOCKING_SESSION,
-
FINAL_BLOCKING_SESSION_STATUS, FINAL_BLOCKING_INSTANCE,
-
FINAL_BLOCKING_SESSION, SEQ#, EVENT#,EVENT,P1TEXT,P1,P1RAW,P2TEXT,P2,P2RAW,
-
P3TEXT,P3,P3RAW,WAIT_CLASS_ID, WAIT_CLASS#,WAIT_CLASS,WAIT_TIME,
-
SECONDS_IN_WAIT,STATE,WAIT_TIME_MICRO,TIME_REMAINING_MICRO,
-
TIME_SINCE_LAST_WAIT_MICRO,SERVICE_NAME, SQL_TRACE, SQL_TRACE_WAITS,
-
SQL_TRACE_BINDS, SQL_TRACE_PLAN_STATS, SESSION_EDITION_ID, CREATOR_ADDR,
-
CREATOR_SERIAL#, ECID
-
from
-
GV$SESSION where inst_id = USERENV(\'Instance\')
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 1 0.01 0.01 0 0 0 0
-
Execute 0 0.00 0.00 0 0 0 0
-
Fetch 0 0.00 0.00 0 0 0 0
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 1 0.01 0.01 0 0 0 0
-
-
Misses in library cache during parse: 1
-
Optimizer mode: CHOOSE
-
Parsing user id: SYS (recursive depth: 1)
-
********************************************************************************
-
-
SQL ID: gzp9y42kcbx6m Plan Hash: 644658511
-
-
select sid,serial#,username
-
from
-
v$session where username=\'SCOTT\'
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 1 0.00 0.00 0 0 0 0
-
Execute 1 0.00 0.00 0 0 0 0
-
Fetch 2 0.00 0.00 0 0 0 1
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 4 0.00 0.00 0 0 0 1
-
-
Misses in library cache during parse: 1
-
Optimizer mode: ALL_ROWS
-
Parsing user id: SYS
-
Number of plan statistics captured: 1
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
1 1 1 NESTED LOOPS (cr=0 pr=0 pw=0 time=231 us cost=0 size=121 card=1)
-
1 1 1 NESTED LOOPS (cr=0 pr=0 pw=0 time=2330 us cost=0 size=108 card=1)
-
1 1 1 FIXED TABLE FULL X$KSUSE (cr=0 pr=0 pw=0 time=1981 us cost=0 size=82 card=1)
-
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)
-
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)
-
-
********************************************************************************
-
-
SQL ID: 3nkd3g3ju5ph1 Plan Hash: 2853959010
-
-
select obj#,type#,ctime,mtime,stime, status, dataobj#, flags, oid$, spare1,
-
spare2
-
from
-
obj$ where owner#=:1 and name=:2 and namespace=:3 and remoteowner is null
-
and linkname is null and subname is null
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 1 0.00 0.00 0 0 0 0
-
Execute 4 0.00 0.00 0 0 0 0
-
Fetch 4 0.00 0.00 0 16 0 4
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 9 0.00 0.00 0 16 0 4
-
-
Misses in library cache during parse: 1
-
Misses in library cache during execute: 1
-
Optimizer mode: CHOOSE
-
Parsing user id: SYS (recursive depth: 1)
-
Number of plan statistics captured: 1
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
1 1 1 TABLE ACCESS BY INDEX ROWID OBJ$ (cr=4 pr=0 pw=0 time=145 us cost=4 size=82 card=1)
-
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)
-
-
********************************************************************************
-
-
SQL ID: 7ng34ruy5awxq Plan Hash: 2542797530
-
-
select i.obj#,i.ts#,i.file#,i.block#,i.intcols,i.type#,i.flags,i.property,
-
i.pctfree$,i.initrans,i.maxtrans,i.blevel,i.leafcnt,i.distkey,i.lblkkey,
-
i.dblkkey,i.clufac,i.cols,i.analyzetime,i.samplesize,i.dataobj#,
-
nvl(i.degree,1),nvl(i.instances,1),i.rowcnt,mod(i.pctthres$,256),
-
i.indmethod#,i.trunccnt,nvl(c.unicols,0),nvl(c.deferrable#+c.valid#,0),
-
nvl(i.spare1,i.intcols),i.spare4,i.spare2,i.spare6,decode(i.pctthres$,null,
-
null,mod(trunc(i.pctthres$/256),256)),ist.cachedblk,ist.cachehit,
-
ist.logicalread
-
from
-
ind$ i, ind_stats$ ist, (select enabled, min(cols) unicols,
-
min(to_number(bitand(defer,1))) deferrable#,min(to_number(bitand(defer,4)))
-
valid# from cdef$ where obj#=:1 and enabled > 1 group by enabled) c where
-
i.obj#=c.enabled(+) and i.obj# = ist.obj#(+) and i.bo#=:1 order by i.obj#
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 1 0.00 0.00 0 0 0 0
-
Execute 5 0.00 0.00 0 0 0 0
-
Fetch 10 0.00 0.00 0 36 0 5
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 16 0.00 0.00 0 36 0 5
-
-
Misses in library cache during parse: 1
-
Misses in library cache during execute: 1
-
Optimizer mode: CHOOSE
-
Parsing user id: SYS (recursive depth: 2)
-
Number of plan statistics captured: 1
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
1 1 1 SORT ORDER BY (cr=8 pr=0 pw=0 time=644 us cost=7 size=372 card=2)
-
1 1 1 HASH JOIN OUTER (cr=8 pr=0 pw=0 time=608 us cost=6 size=372 card=2)
-
1 1 1 NESTED LOOPS OUTER (cr=5 pr=0 pw=0 time=177 us cost=2 size=286 card=2)
-
1 1 1 TABLE ACCESS CLUSTER IND$ (cr=4 pr=0 pw=0 time=100 us cost=2 size=182 card=2)
-
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)
-
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)
-
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)
-
0 0 0 VIEW (cr=3 pr=0 pw=0 time=202 us cost=3 size=43 card=1)
-
0 0 0 SORT GROUP BY (cr=3 pr=0 pw=0 time=200 us cost=3 size=15 card=1)
-
0 0 0 TABLE ACCESS CLUSTER CDEF$ (cr=3 pr=0 pw=0 time=149 us cost=2 size=15 card=1)
-
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)
-
-
********************************************************************************
-
-
SQL ID: 5n1fs4m2n2y0r Plan Hash: 299250003
-
-
select pos#,intcol#,col#,spare1,bo#,spare2,spare3
-
from
-
icol$ where obj#=:1
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 1 0.00 0.00 0 0 0 0
-
Execute 5 0.00 0.00 0 0 0 0
-
Fetch 20 0.00 0.00 0 40 0 15
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 26 0.00 0.00 0 40 0 15
-
-
Misses in library cache during parse: 1
-
Misses in library cache during execute: 1
-
Optimizer mode: CHOOSE
-
Parsing user id: SYS (recursive depth: 2)
-
Number of plan statistics captured: 1
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
1 1 1 TABLE ACCESS BY INDEX ROWID ICOL$ (cr=4 pr=0 pw=0 time=52 us cost=2 size=54 card=2)
-
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)
-
-
********************************************************************************
-
-
SQL ID: 83taa7kaw59c1 Plan Hash: 3765558045
-
-
select name,intcol#,segcol#,type#,length,nvl(precision#,0),decode(type#,2,
-
nvl(scale,-127/*MAXSB1MINAL*/),178,scale,179,scale,180,scale,181,scale,182,
-
scale,183,scale,231,scale,0),null$,fixedstorage,nvl(deflength,0),default$,
-
rowid,col#,property, nvl(charsetid,0),nvl(charsetform,0),spare1,spare2,
-
nvl(spare3,0)
-
from
-
col$ where obj#=:1 order by intcol#
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 1 0.00 0.00 0 0 0 0
-
Execute 5 0.00 0.00 0 0 0 0
-
Fetch 31 0.00 0.00 0 16 0 26
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 37 0.00 0.00 0 16 0 26
-
-
Misses in library cache during parse: 1
-
Misses in library cache during execute: 1
-
Optimizer mode: CHOOSE
-
Parsing user id: SYS (recursive depth: 2)
-
Number of plan statistics captured: 1
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
4 4 4 SORT ORDER BY (cr=4 pr=0 pw=0 time=54 us cost=3 size=708 card=12)
-
4 4 4 TABLE ACCESS CLUSTER COL$ (cr=4 pr=0 pw=0 time=27 us cost=2 size=708 card=12)
-
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)
-
-
********************************************************************************
-
-
SQL ID: 3ktacv9r56b51 Plan Hash: 4184428695
-
-
select owner#,name,namespace,remoteowner,linkname,p_timestamp,p_obj#,
-
nvl(property,0),subname,type#,d_attrs
-
from
-
dependency$ d, obj$ o where d_obj#=:1 and p_obj#=obj#(+) order by order#
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 2 0.00 0.00 0 0 0 0
-
Execute 2 0.00 0.00 0 0 0 0
-
Fetch 12 0.00 0.00 0 27 0 10
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 16 0.00 0.00 0 27 0 10
-
-
Misses in library cache during parse: 1
-
Misses in library cache during execute: 1
-
Optimizer mode: CHOOSE
-
Parsing user id: SYS (recursive depth: 1)
-
Number of plan statistics captured: 2
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
1 5 9 SORT ORDER BY (cr=14 pr=0 pw=0 time=304 us cost=11 size=330 card=3)
-
1 5 9 NESTED LOOPS OUTER (cr=14 pr=0 pw=0 time=297 us cost=10 size=330 card=3)
-
1 5 9 TABLE ACCESS BY INDEX ROWID DEPENDENCY$ (cr=4 pr=0 pw=0 time=80 us cost=4 size=84 card=3)
-
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)
-
1 3 5 TABLE ACCESS BY INDEX ROWID OBJ$ (cr=10 pr=0 pw=0 time=157 us cost=2 size=82 card=1)
-
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)
-
-
********************************************************************************
-
-
SQL ID: 87gaftwrm2h68 Plan Hash: 1218588913
-
-
select o.owner#,o.name,o.namespace,o.remoteowner,o.linkname,o.subname
-
from
-
obj$ o where o.obj#=:1
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 1 0.00 0.00 0 0 0 0
-
Execute 1 0.00 0.00 0 0 0 0
-
Fetch 1 0.00 0.00 0 3 0 1
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 3 0.00 0.00 0 3 0 1
-
-
Misses in library cache during parse: 1
-
Misses in library cache during execute: 1
-
Optimizer mode: CHOOSE
-
Parsing user id: SYS (recursive depth: 2)
-
Number of plan statistics captured: 1
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
1 1 1 TABLE ACCESS BY INDEX ROWID OBJ$ (cr=3 pr=0 pw=0 time=38 us cost=3 size=82 card=1)
-
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)
-
-
********************************************************************************
-
-
SQL ID: ga9j9xk5cy9s0 Plan Hash: 1697022209
-
-
select /*+ index(idl_sb4$ i_idl_sb41) +*/ piece#,length,piece
-
from
-
idl_sb4$ where obj#=:1 and part=:2 and version=:3 order by piece#
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 3 0.00 0.00 0 0 0 0
-
Execute 3 0.00 0.00 0 0 0 0
-
Fetch 7 0.00 0.00 1 18 0 4
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 13 0.00 0.00 1 18 0 4
-
-
Misses in library cache during parse: 1
-
Misses in library cache during execute: 1
-
Optimizer mode: CHOOSE
-
Parsing user id: SYS (recursive depth: 1)
-
Number of plan statistics captured: 3
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
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)
-
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)
-
-
********************************************************************************
-
-
SQL ID: cvn54b7yz0s8u Plan Hash: 3246118364
-
-
select /*+ index(idl_ub1$ i_idl_ub11) +*/ piece#,length,piece
-
from
-
idl_ub1$ where obj#=:1 and part=:2 and version=:3 order by piece#
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 3 0.00 0.00 0 0 0 0
-
Execute 3 0.00 0.00 0 0 0 0
-
Fetch 6 0.00 0.00 3 20 0 5
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 12 0.00 0.00 3 20 0 5
-
-
Misses in library cache during parse: 1
-
Misses in library cache during execute: 1
-
Optimizer mode: CHOOSE
-
Parsing user id: SYS (recursive depth: 1)
-
Number of plan statistics captured: 3
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
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)
-
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)
-
-
********************************************************************************
-
-
SQL ID: c6awqs517jpj0 Plan Hash: 1319326155
-
-
select /*+ index(idl_char$ i_idl_char1) +*/ piece#,length,piece
-
from
-
idl_char$ where obj#=:1 and part=:2 and version=:3 order by piece#
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 3 0.00 0.00 0 0 0 0
-
Execute 3 0.00 0.00 0 0 0 0
-
Fetch 4 0.00 0.01 1 9 0 1
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 10 0.00 0.01 1 9 0 1
-
-
Misses in library cache during parse: 1
-
Misses in library cache during execute: 1
-
Optimizer mode: CHOOSE
-
Parsing user id: SYS (recursive depth: 1)
-
Number of plan statistics captured: 3
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
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)
-
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)
-
-
********************************************************************************
-
-
SQL ID: 39m4sx9k63ba2 Plan Hash: 2317816222
-
-
select /*+ index(idl_ub2$ i_idl_ub21) +*/ piece#,length,piece
-
from
-
idl_ub2$ where obj#=:1 and part=:2 and version=:3 order by piece#
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 3 0.00 0.00 0 0 0 0
-
Execute 3 0.00 0.00 0 0 0 0
-
Fetch 4 0.00 0.00 1 11 0 2
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 10 0.00 0.01 1 11 0 2
-
-
Misses in library cache during parse: 1
-
Misses in library cache during execute: 1
-
Optimizer mode: CHOOSE
-
Parsing user id: SYS (recursive depth: 1)
-
Number of plan statistics captured: 3
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
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)
-
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)
-
-
********************************************************************************
-
-
SQL ID: 83sp8xb9ytgkv Plan Hash: 0
-
-
BEGIN dbms_system.set_ev(21,2615,10046,12,\'SCOTT\'); END;
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 1 0.00 0.00 0 0 0 0
-
Execute 1 0.00 0.00 0 0 0 1
-
Fetch 0 0.00 0.00 0 0 0 0
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 2 0.00 0.00 0 0 0 1
-
-
Misses in library cache during parse: 1
-
Optimizer mode: ALL_ROWS
-
Parsing user id: SYS
-
********************************************************************************
-
-
SQL ID: b1wc53ddd6h3p Plan Hash: 1637390370
-
-
select audit$,options
-
from
-
procedure$ where obj#=:1
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 2 0.00 0.00 0 0 0 0
-
Execute 2 0.00 0.00 0 0 0 0
-
Fetch 2 0.00 0.00 0 6 0 2
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 6 0.00 0.00 0 6 0 2
-
-
Misses in library cache during parse: 1
-
Misses in library cache during execute: 1
-
Optimizer mode: CHOOSE
-
Parsing user id: SYS (recursive depth: 1)
-
Number of plan statistics captured: 2
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
1 1 1 TABLE ACCESS BY INDEX ROWID PROCEDURE$ (cr=3 pr=0 pw=0 time=46 us cost=2 size=47 card=1)
-
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)
-
-
********************************************************************************
-
-
SQL ID: 8swypbbr0m372 Plan Hash: 893970548
-
-
select order#,columns,types
-
from
-
access$ where d_obj#=:1
-
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 2 0.00 0.00 0 0 0 0
-
Execute 2 0.00 0.00 0 0 0 0
-
Fetch 9 0.00 0.00 0 18 0 7
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 13 0.00 0.00 0 18 0 7
-
-
Misses in library cache during parse: 1
-
Misses in library cache during execute: 1
-
Optimizer mode: CHOOSE
-
Parsing user id: SYS (recursive depth: 1)
-
Number of plan statistics captured: 2
-
-
Rows (1st) Rows (avg) Rows (max) Row Source Operation
-
---------- ---------- ---------- ---------------------------------------------------
-
7 4 7 TABLE ACCESS BY INDEX ROWID ACCESS$ (cr=9 pr=0 pw=0 time=56 us cost=3 size=161 card=7)
-
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)
-
-
-
-
-
********************************************************************************
-
-
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 3 0.00 0.00 0 0 0 0
-
Execute 4 0.01 0.01 0 0 0 1
-
Fetch 4 0.01 0.01 0 0 0 2
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 11 0.02 0.03 0 0 0 3
-
-
Misses in library cache during parse: 3
-
Misses in library cache during execute: 2
-
-
-
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
-
-
call count cpu elapsed disk query current rows
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
Parse 27 0.03 0.03 0 0 0 0
-
Execute 61 0.01 0.02 0 0 0 0
-
Fetch 133 0.01 0.02 6 286 0 103
-
------- ------ -------- ---------- ---------- ---------- ---------- ----------
-
total 221 0.06 0.08 6 286 0 103
-
-
Misses in library cache during parse: 16
-
Misses in library cache during execute: 15
-
-
4 user SQL statements in session.
-
27 internal SQL statements in session.
-
31 SQL statements in session.
-
********************************************************************************
-
Trace file: HOEGH_ora_16427.trc
-
Trace file compatibility: 11.1.0.7
-
Sort options: default
-
-
1 session in tracefile.
-
4 user SQL statements in trace file.
-
27 internal SQL statements in trace file.
-
31 SQL statements in trace file.
-
20 unique SQL statements in trace file.
-
534 lines in trace file.
- 337 elapsed seconds in trace file.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28389881/viewspace-1745592/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- sql_trace and 10046事件SQL事件
- 拜年+散分貼《Oracle SQL_TRACE和10046事件優化SQL例項》OracleSQL事件優化
- sql_trace/ 10046 整理SQL
- sql_trace 和 events 跟蹤事件SQL事件
- 使用SQL_TRACE /10046進行資料庫診斷SQL資料庫
- sql_trace、10046、10053、tkprofSQL
- Oracle SQL Trace 和 10046 事件OracleSQL事件
- Oracle SQL Trace 和10046 事件OracleSQL事件
- oracle 10046 事件使用方法Oracle事件
- 10046事件事件
- 10046事件概述事件
- 10046事件演示事件
- 10046事件(轉)事件
- 在SQL*PLUS下使用10046事件例子SQL事件
- 對使用dblink的10046事件跟蹤事件
- 10046事件詳解事件
- 設定10046事件事件
- 關於10046事件事件
- 10046 事件 與 10053 事件事件
- 使用10046事件跟蹤分析執行計劃事件
- 使用10046事件檢視oracle執行計劃事件Oracle
- 使用oracle的10046事件跟蹤SQL語句Oracle事件SQL
- 使用10046事件 +10704事件對索引線上重建的跟蹤事件索引
- 如何收集用來診斷效能問題的10046 Trace(SQL_TRACE) (文件 ID 1523462.1)SQL
- sql_trace的使用SQL
- oracle event 10046 level_事件Oracle事件
- 10046事件跟蹤會話sql事件會話SQL
- ORACLE 10046事件詳解-轉載Oracle事件
- 深入理解Oracle除錯事件:10046事件詳解Oracle除錯事件
- 啟用跟蹤事件10046---06事件
- 跟蹤SQL - SQL Trace 及 10046 事件SQL事件
- 查當前的10046 事件級別事件
- SQL TRACE和TKPROF,10046的使用步驟SQL
- Oracle SQL_TRACE使用小結OracleSQL
- 事件代理如何使用?事件
- 利用10046事件收集SQL的trace檔案事件SQL
- oracle 10046事件故障診斷一例Oracle事件
- [20180417]使用10046事件需要什麼許可權.txt事件