As a DBA we face a performance issue on our database. Mostly we hit query performance issues.
We need to clarify to know about more details about query.
Oracle provides to generate trace files which is called 10046 trace,
If you want to generate the Session Tracing you have to follow these steps:
1- Login as sys user by using sqlplus utility.
With the introduction of the new diagnosability infrastructure introduced in Oracle Database 11g Release 1 and above, traces and core files are placed in a location controlled by the DIAGNOSTIC_DEST initialization parameter.
To show the location of the DIAGNOSTIC_DEST, the following command can be used:
SQL> show parameter diagnostic_dest
spool mytrace.out set timing on set time on session set events '10046 trace name context forever, level 12'; alter session set statistics_level=all; alter session set max_dump_file_size = unlimited; alter session set tracefile_identifier='MENTION_NAME_OF_TRACE'; alter session set timed_statistics = true; #################################### Run the query or the code here #################################### select 'close the cursor' from dual;alter session set events '10046 trace name context off';spool offexit;
Please do not forget to close trace!
exit is very important to complete and close the trace.
you can change the name of the trace depends on what you want
Close the trace after you finished to complete gathering information.
We select from dual to ensure ensure the previous cursor is closed.
Now you can use the tkprof to make the trace more readable, tkprof located under $ORACLE_HOME/bin path