There are multiple methods for enabling tracing for sessions in oracle.

1. Enabling tracing for all session of a user.

             For this we need to create a trigger.

2. Enabling trace for a single session(using dbms_system)

3.  Enabling trace using oradebug.

4. 10053 trace:

10053 trace is is known as optimizer trace. Below are steps generating 10053 trace for a sql statement.

Note: To generate 10053 trace, we need to hard parse the query, So flush the sql statement from shared pool . 

            Alternatively you can generate the 10053 trace, without executing or without hardparsing the sql statement using DBMS_SQLDIAG

suppose sql_id = dmx08r6ayx800
output trace_file=TEST_OBJ3_TRC

5. Enable trace for a sql id :

 

alter system set events ‘sql_trace [sql:4dz8h59sdf2gv9]’;