一、对当前的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=52card=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.

oradebug 10046的更多相关文章

  1. bbed改动undo段状态(ORA-01578)

    ZBDBA@orcl11g>select * from zbdba; select * from zbdba * ERROR at line 1: ORA-01578: ORACLE data ...

  2. 通过10046 event来获取真实的执行计划

    获取SQL执行计划的方式有很多,但是某些时候获取的SQL执行计划并不是准确的,只有在SQL真实执行之后获取到的SQL PLAN才是真实准确的,其他方式(如,explain plan)获取到的执行计划都 ...

  3. Oracle 11g R2性能优化 10046 event

    作为SQL Trace的扩展功能,Oracle 10046 event(10046事件)是一个重要的调试事件,也可以说是系统性能分析时最重要的一个事件,它包含比SQL Trace更多的信息.但可惜的是 ...

  4. 10046 event 知多少

    10046 event 知多少 2017年5月10日 10:08 1.在当前session级打开trace 适用于SQL语句可以在新的session创建后再运行. 在session级收集10046 t ...

  5. Oracle SQL Trace 和 10046 事件

    http://blog.csdn.net/tianlesoftware/article/details/5857023 一. SQL_TRACE 当SQL语句出现性能问题时,我们可以用SQL_TRAC ...

  6. 网罗收集10046的各种Case,方便trace信息的收集

    每逢与遇到SQL相关性能,我们总是需要收集10046的,来查看和诊断问题.因为10046真实的反应的SQL语句执行的时候的真实信息,解析,执行,获取的时间消耗,row source operation ...

  7. 用10046 跟踪exp

    之前写过一个blog,Oracle expdp为什么比exp快,原理是什么,是从官方文档中获知的,如今通过10046来分析exp的过程. C:\Users\Administrator>exp L ...

  8. 10046事件sql_trace跟踪

    查看 sql 执行计划的方法有许多种, 10046 事件就是其中的一种. 与其他查看 sql 执行计划不同, 当我们遇到比较复杂的 sql 语句, 我们可以通过 10046 跟踪 sql 得到执行计划 ...

  9. 深入理解Oracle调试事件:10046事件详解

    10046事件是SQL_TRACE的扩展,被戏称为"吃了兴奋剂的SQL_TRACE"       有效的追踪级别:              ① 0级:SQL_TRACE=FASL ...

随机推荐

  1. 学习 Docker 操作系统版本选择

    近来有时间一直在捣鼓 Docker.因为服务器选择的是 CentOS 版本,所以实验的环境选择的一直是 CentOS.如果是个人玩 Docker,优先选择 ubuntu.如果需要选择 CentOS 的 ...

  2. 2018-11-16 中文代码示例之Programming in Scala笔记第四五六章

    续前文: 中文代码示例之Programming in Scala学习笔记第二三章. 同样仅节选有意思的例程部分作演示之用. 源文档仍在: program-in-chinese/Programming_ ...

  3. 申请Office 365一年免费的开发者账号攻略(2018年10月份版本)

    要进行Office 365开发,当然需要有完整的Office 365环境才可以.为了便于广大开发人员快速地启动这项工作,微软官方给所有开发人员提供了免费的一年开发者账号   那么如何申请Office ...

  4. Android为TV端助力 很详细的序列化过程Parcelable

    直接上代码:注释都写的很清楚了. public class Entry implements Parcelable{ public int userID; public String username ...

  5. Physical Plausible Shading

    问所有人一个简单的问题,为什么我们做片子,CG生产的效果,就是不如论文中样图结果.难道是论文中用了某些神奇的黑科技?或者是依赖PS伪造的图?你当然不可能怀疑Cornell.Stanford这些一流机构 ...

  6. 章节二、1-java概述-数据类型

    一.数据类型 1.基本数据类型 a.数值型 1.整数:byte(1个字节=8位) min:-128 max:127 default:0 .short(2个字节=16位) min:-32768 max: ...

  7. html:常见行内标签,常见块级标签,常见自闭合标签

    本文内容: 常见行内标签 常见块级标签 常见自闭合标签 首发日期:2018-02-12 修改: 2018-04-25:删除了不常用的标签 常见行内标签: 什么是行内标签: 行内标签就是在页面内只占据刚 ...

  8. SpringBoot集成spring-data-jpa注入Bean失败

    当项目结构正常(spring管理的Bean在SrpingBoot启动类平级或下级,支持spring扫描时),实现类上加 @Service注解,在实现类中注入dao层的Bean时,项目无法启动,无法找到 ...

  9. Lua中的#

    Lua中的 对字符串来说,#取字符串的长度,但对于table需要注意. lua的table可以用数字或字符串等作为key, #号得到的是用整数作为索引的最开始连续部分的大小, 如果t[1] == ni ...

  10. Linux中shell和子shell一点点理解

    Linux执行脚本有两种方式,主要区别在于是否建立子shell   1.像sh,bash,./命令是用来执行shell脚本的,在bash/sh命令下,脚本文件可以无"执行权限",即 ...