一、对当前的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. IIS服务器被配置为不列出此目录的内容

    使用 IIS 管理器启用目录浏览. 打开 IIS 管理器. 在“功能”视图中,双击“目录浏览”. 在“目录浏览”页上,在“操作”窗格中单击“启用”.

  2. angularJs学习笔记-入门

    1.angularJs简介 angularJs是一个MV*的javascript框架(Model-View-Whatever,不管是MVVM还是MVC,统归MDV(model drive view)) ...

  3. webpack+vue+vueRouter模块化构建完整项目实例详细步骤-入门篇

    新建项目 开始(确认已经安装node环境和npm包管理工具) 1.新建项目文件名为start_vuedemo 2.npm init -y 初始化项目,我的win7系统,工程在d盘的vue_test_p ...

  4. 前端了解即可:OSS客户端如何使用,以实现资源分离

    前一阵,应为项目需要,才简单整理了一下oss客户端的使用,做静态资源分离,及在项目中引入路径.接下来讲解记录一下,阿里云对象存储(Object Storage Service,简称OSS)客户端的基础 ...

  5. Android项目实战(四十三):夜神模拟器

    一.下载模拟器到电脑 夜神模拟器 二.环境配置 计算机--系统--高级系统设置--环境变量 PATH 里面加入夜神模拟器的安装目录下的bin文件 三.启动模拟器 四.运行cmd命令,cd到夜神安装目录 ...

  6. windows server 2008 r2安装windows media player

    1.打开“服务器管理器”: 2.依次单击“功能” →  “添加功能”: 3.勾选“桌面体验”和“优质Windows音频视频体验”: 4.单击“安装”按钮:安装完毕,根据提示重新启动计算机即可.

  7. 添加用户到sudoers

    ** is not in the sudoersfile.  This incident will bereported.” (用户不在sudoers文件中……) 处理这个问题很简单,但应该先理解其原 ...

  8. 几个时间:UTC、GMT、本地时间、Unix时间戳

    UTC(Coordinated Universal Time)时间:协调世界时,即世界标准时间 GMT(Greenwich Mean Time):格林威治/格林尼治时间 GMT=UTC,均使用秒数来计 ...

  9. Linux下安装JDK,Tomcat,Mysql详细教程

    1. 概述 今天教大家在linux下安装jdk,mysql以及tomcat.在javaweb开发中,最后完成的项目代码,一般都是布在linux服务器下的.因为linux服务器可以说是安全性稳定性都比w ...

  10. 5. svg学习笔记-坐标系变换

    之前我们编写图形元素的时候,编写好了位置大小就是固定的,通过坐标系变换,可以移动缩放,旋转图形,但必须声明的是,进行变换时是图形相对于坐标系的变化,就是图形是不发生变化的,而是坐标系发生了变化,比如缩 ...