[10046]oradebug 10046的使用

一、对当前的session使用oradebug命令:

SQL> conn / as sysdba

Connected.

SQL> oradebug setmypid

Statement processed.

或者对其他session做跟踪

--连接到一个外部服务进程,且pid=v$process.pid

oradebug setorapid pid

--连接到一个外部服务进程,且spid=v$process.spid

oradebug setospid spid

二、激活10046事件

SQL> oradebug event 10046 trace name context forever,level 12;

Statement processed.

三、执行目标sql语句

SQL> select empno,ename,dname from scott.emp,scott.dept where emp.deptno=dept.deptno;

     EMPNO ENAME      DNAME

---------- ---------- --------------

      7782 CLARK      ACCOUNTING

      ...省略相同内容

      7654 MARTIN     SALES

14 rows selected.

四、查看对应的trc文件及目录

SQL> oradebug tracefile_name;

/u01/oracle/diag/rdbms/neal/neal/trace/neal_ora_18691.trc

五、关闭当前的10046跟踪事件

SQL> oradebug event 10046 trace name context off;

Statement processed.

六、使用tkprof来格式化

[oracle@server ~]$ tkprof /u01/oracle/diag/rdbms/neal/neal/trace/neal_ora_18691.trc /tmp/neal_ora_18691.trc

七、查看得到的neal_ora_18691.trc文件

SQL ID: 3yfu3wh150aqt Plan Hash: 844388907

select empno,ename,dname

from

 scott.emp,scott.dept where emp.deptno=dept.deptno

call     count       cpu    elapsed       disk      query    current        rows

------- ------  -------- ---------- ---------- ---------- ----------  ----------

Parse        1      0.03       0.04          0        161          0           0

Execute      1      0.00       0.00          0          0          0           0

Fetch        2      0.00       0.02          8         10          0          14

------- ------  -------- ---------- ---------- ---------- ----------  ----------

total        4      0.03       0.07          8        171          0          14

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

---------- ---------- ----------  ---------------------------------------------------

        14         14         14  MERGE JOIN  (cr=10 pr=8 pw=0 time=29081 us cost=6 size=364 card=14)

         4          4          4   TABLE ACCESS BY INDEX ROWID DEPT (cr=4 pr=2 pw=0 time=19696 us cost=2 size=52 card=4)

         4          4          4    INDEX FULL SCAN PK_DEPT (cr=2 pr=1 pw=0 time=18734 us cost=1 size=0 card=4)(object id 87107)

        14         14         14   SORT JOIN (cr=6 pr=6 pw=0 time=9416 us cost=4 size=182 card=14)

        14         14         14    TABLE ACCESS FULL EMP (cr=6 pr=6 pw=0 time=9371 us cost=3 size=182 card=14)

Elapsed times include waiting on following events:

  Event waited on                             Times   Max. Wait  Total Waited

  ----------------------------------------   Waited  ----------  ------------

  SQL*Net break/reset to client                   2        0.00          0.00

  SQL*Net message to client                       3        0.00          0.00

  SQL*Net message from client                     3       10.81         20.69

  Disk file operations I/O                        1        0.00          0.00

  db file sequential read                         3        0.01          0.01

  db file scattered read                          1        0.00          0.00

********************************************************************************

OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS

call     count       cpu    elapsed       disk      query    current        rows

------- ------  -------- ---------- ---------- ---------- ----------  ----------

Parse        1      0.03       0.04          0        161          0           0

Execute      1      0.00       0.00          0          0          0           0

Fetch        2      0.00       0.02          8         10          0          14

------- ------  -------- ---------- ---------- ---------- ----------  ----------

total        4      0.03       0.07          8        171          0          14

Misses in library cache during parse: 1

Elapsed times include waiting on following events:

  Event waited on                             Times   Max. Wait  Total Waited

  ----------------------------------------   Waited  ----------  ------------

  SQL*Net message to client                       6        0.00          0.00

  SQL*Net message from client                     6       34.85         80.64

  Disk file operations I/O                        1        0.00          0.00

  db file sequential read                         3        0.01          0.01

  SQL*Net break/reset to client                   2        0.00          0.00

  db file scattered read                          1        0.00          0.00

OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS

call     count       cpu    elapsed       disk      query    current        rows

------- ------  -------- ---------- ---------- ---------- ----------  ----------

Parse       13      0.01       0.01          0          0          0           0

Execute     82      0.03       0.08          0          0          0           0

Fetch      104      0.00       0.00          1        261          0          93

------- ------  -------- ---------- ---------- ---------- ----------  ----------

total      199      0.05       0.09          1        261          0          93

Misses in library cache during parse: 12

Misses in library cache during execute: 12

Elapsed times include waiting on following events:

  Event waited on                             Times   Max. Wait  Total Waited

  ----------------------------------------   Waited  ----------  ------------

  Disk file operations I/O                        1        0.00          0.00

  db file sequential read                         1        0.00          0.00

    1  user  SQL statements in session.

   17  internal SQL statements in session.

   18  SQL statements in session.

********************************************************************************

Trace file: /u01/oracle/diag/rdbms/neal/neal/trace/neal_ora_18691.trc

Trace file compatibility: 11.1.0.7

Sort options: default

       1  session in tracefile.

       1  user  SQL statements in trace file.

      17  internal SQL statements in trace file.

      18  SQL statements in trace file.

      17  unique SQL statements in trace file.

    1323  lines in trace file.

      10  elapsed seconds in trace file.


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29812844/viewspace-1988820/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29812844/viewspace-1988820/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值