10046 trace event
What is 10046 trace events
whenever we want to tune any sql statement and want to know about waits and bind variable ...then we can use 10046 trace events.
How to use 10046 trace events
First define trace identifier for generated trace files so we can easily identify our trace files in UDUMP folder.
SQL> alter session set tracefile_identifier='MYSESSION';
Enable 10046 tracing.
SQL> alter session set events '10046 trace name context forever, level 8';
Now execute SQL Statements...
select e.empno, e.ename, d.dname, d.deptno
from emp e , dept d
where e.deptno = d.deptno;
Disable 10046 tracing.
SQL> alter session set events '10046 trace name context off';
Check UDUMP directory for generated trace file.
file name like "XXXX_MYSESSION.TRC"
C:\Oracle\admin\ora9i\udump>dir *MYSESSION.trc
Now generated trace file is RAW trace file and very hard to read and understand ...so through TKPROF utility create readable output file for generated trace file.
C:\Oracle\admin\ora9i\udump>tkprof ORA01904_MYSESSION.TRC c:\output.log
TKPROF: Release 10.1.0.5.0 - Production on Wed Oct 17 19:01:44 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Open c:\output.log file and analyze it. below is content of output.log file
select e.empno, e.ename, d.dname, d.deptno
from emp e , dept d
where e.deptno = d.deptno
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.29 0.31 2 0 2 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 3 30 2 14
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.29 0.31 5 30 4 14
Misses in library cache during parse: 1
Optimizer mode: CHOOSE
Parsing user id: 66
---Below is execution plan
Rows Row Source Operation
------- ---------------------------------------------------
14 NESTED LOOPS
14 TABLE ACCESS FULL EMP
14 TABLE ACCESS BY INDEX ROWID DEPT
14 INDEX UNIQUE SCAN (object id 32119)
---Waits time information.
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
db file sequential read 3 0.00 0.00
SQL*Net message from client 2 56.49 56.51
10046 Trace Level
Level 1
Basic trace level. Like the standard SQL_TRACE trace file. Provides statistics for parse, execute, fetch, commit and rollback database calls.
Level 4
Displays bind variables
Level 8
Displays wait statistics
Level 12
Displays wait statistics and bind variables
No comments:
Post a Comment