You all surely know oradebug tool to activate SQL trace of another session or to generate the hanganalyze and systemstate reports to Oracle support when your database is hanging.
Tanel Poder is revealing an extension of this usage in his post The full power of Oracle’s diagnostic events, part 2: ORADEBUG DOC and 11g improvements.
All is starting from the official oradebug documentation:
SQL> oradebug doc Internal Documentation ********************** EVENT Help ON events (syntax, event list, ...) COMPONENT [<comp_name>] List ALL components OR describe <comp_name>
You can obtain additional information using:
SQL> oradebug doc event SQL> oradebug doc event name SQL> oradebug doc event scope SQL> oradebug doc event filter SQL> oradebug doc event action
Deep investigation is required but one looks very interesting, trace one particular sql_id over time…
As an example I start by creating the below table with my Oracle account (YJAQUIER):
SQL> CREATE TABLE toto (val NUMBER, descr VARCHAR2(50)); TABLE created. SQL> INSERT INTO toto VALUES (1,'One'); 1 ROW created. SQL> COMMIT; COMMIT complete.
Then using something like below I find my SQL*Developer session:
SELECT * FROM v$session v, v$process p WHERE v.paddr=p.addr AND v.username='YJAQUIER';
I then execute the below query:
SELECT /* Yannick */ * FROM toto WHERE val=1;
And find its associated sql_id using:
SELECT * FROM v$sql WHERE sql_text LIKE 'select /* Yannick */%';
I can know activate tracing for this sql_id for my session:
SQL> oradebug setospid 30926 Oracle pid: 42, Unix process pid: 30926, image: oracle@server1 SQL> oradebug event sql_trace[SQL: sql_id=100035jk2ztcg] Statement processed.
The trace file can be found in this directory:
You can laso find its full name using v$process.tracefile column…
If you look at trace file you will see that tracing is taken only when I execute the monitored query. Any other statements are NOT monitored…
To stop tracing issue (you may need to reconnect to spid if you close your session):
SQL> oradebug event sql_trace off Statement processed.
- How to Enable SQL_TRACE for Another Session or in MTS Using Oradebug [ID 1058210.6]
- Diagnosing Database Hanging Issues [ID 61552.1]
- ORADEBUG DOC
- MariaDB Connector/J high availability features testing - May 4, 2017
- Enhanced password strength in MySQL with validate_password plugin - April 12, 2017
- Automatic extended statistics to improve performance - April 6, 2017
- OGG-03517 when moving to Unicode from any other character set - March 10, 2017
- Audit creation and deletion of users for SOX evidences - February 17, 2017
- PL/SQL performance tuning with bulk SQL/binding and parallelism - February 14, 2017