ITPub博客

首页 > 数据库 > Oracle > 使用10046事件查看oracle执行计划

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

原创 Oracle 作者:sky850623 时间:2015-07-19 10:45:31 0 删除 编辑
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博客 ” ,链接:https://blog.itpub.net/26937943/viewspace-1739166/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: openfiler安装使用
请登录后发表评论 登录
全部评论

注册时间:2013-05-30

  • 博文量
    154
  • 访问量
    515358