10046入门:使用 10046 查看执行计划并读懂 trace文件

*************************************************************
1.开启10046
*************************************************************


SQL> oradebug setmypid  
Statement processed.  
  
// 激活 10046 事件  
SQL> oradebug event 10046 trace name context forever,level 12;  
Statement processed.  
  
SQL> select count(*) from scott.tblorders;

  COUNT(*)
----------
       167

  
// 在当前 session 关闭 10046 事件  
SQL> oradebug event 10046 trace name context off;  
Statement processed.  
  

// 使用 oradebug tracefile_name 可以直接看到生成的 trace 文件的位置  
SQL> oradebug tracefile_name;  
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_2551.trc


*************************************************************
2.直接读取文件
*************************************************************

----------------------trace文件内容

Trace file /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_2551.trc
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1
System name:	Linux
Node name:	timesten.ocp.com
Release:	2.6.32-431.el6.x86_64
Version:	#1 SMP Fri Nov 22 03:15:09 UTC 2013
Machine:	x86_64
Instance name: orcl
Redo thread mounted by this instance: 1
Oracle process number: 20
Unix process pid: 2551, image: [email protected] (TNS V1-V3)


*** 2015-02-10 17:34:40.127
*** SESSION ID:(132.9911) 2015-02-10 17:34:40.127
*** CLIENT ID:() 2015-02-10 17:34:40.127
*** SERVICE NAME:(SYS$USERS) 2015-02-10 17:34:40.127
*** MODULE NAME:([email protected] (TNS V1-V3)) 2015-02-10 17:34:40.127
*** ACTION NAME:() 2015-02-10 17:34:40.127
 
Processing Oradebug command 'setmypid'

*** 2015-02-10 17:34:40.127
Oradebug command 'setmypid' console output: <none>

*** 2015-02-10 17:34:48.483
Processing Oradebug command 'event 10046 trace name context forever,level 12'

*** 2015-02-10 17:34:48.484
Oradebug command 'event 10046 trace name context forever,level 12' console output: <none>
WAIT #0: nam='SQL*Net message to client' ela= 2 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1423560888484461

*** 2015-02-10 1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值