使用10046事件查看oracle执行计划

SQL> conn / as sysdba
已连接。
1.我们先激活10046事件,我们是oradebug命令来激活。
SQL> oradebug setmypid
已处理的语句
SQL> oradebug event 10046 trace name context forever,level 12
已处理的语句
2.执行sql语句
SQL> select * from test.norm_tab where col2=100;
        ID       COL2       COL3
---------- ---------- ----------
        99        100        101
3.使用oradebug tracefile_name 命令查看当前session所对应的trace文件路径和名称
SQL> oradebug tracefile_name
e:\oracle\product\10.2.0\admin\orcl\udump\orcl_ora_2676.trc
4.关闭当前session 中的10046事件:
SQL> oradebug event 10046 trace name context off
已处理的语句
5.使用tkprof工具生成报告
C:\>tkprof e:\oracle\product\10.2.0\admin\orcl\udump\orcl_ora_2676.trc c:\b.txt

TKPROF: Release 10.2.0.1.0 - Production on 星期日 7月 19 10:48:16 2015

Copyright (c) 1982, 2005, Oracle.  All rights reserved.
********************************************************************************
select * 
from
 test.norm_tab where col2=100

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.05          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.00       0.00          0          4          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.00       0.05          0          4          0           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  TABLE ACCESS BY INDEX ROWID NORM_TAB (cr=4 pr=0 pw=0 time=50 us)
      1   INDEX RANGE SCAN IDX_NOR_TAB_COL2 (cr=3 pr=0 pw=0 time=38 us)(object id 58507)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       2        0.00          0.00
  SQL*Net message from client                     2        0.01          0.02

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

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

转载于:http://blog.itpub.net/26937943/viewspace-1739166/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值