Skip to menu

Korea Oracle User Group

Guru's Articles

How do I capture a 10053 trace for a SQL statement called in a PL/SQL package?

Traditionally if you wanted to capture an Optimizer trace (10053) for a SQL statement you would issue an alter session command to switch on a 10053 trace for that entire session, and then issue the SQL statement you wanted to capture the trace for. Once the statement completed you would exit the session to disable the trace. You would then look in theUSER_DUMP_DEST directory for the trace file.


But what if the SQL statement you were interested  in was actually called as part of a PL/SQL package? Oracle Database 11g, introduced a new diagnostic events infrastructure, which greatly simplifies the task of generating a 10053 trace for a specific SQL statement in a PL/SQL package. All you will need to know is the SQL_ID for the statement you are interested in. Instead of turning on the trace event for the entire session you can now switch it on for a specific SQL ID. Oracle will then capture a 10053 trace for the corresponding SQL statement when it is issued in that session. Remember the SQL statement still has to be hard parsed for the 10053 trace to be generated.  Let's begin our example by creating a PL/SQL package called 'cal_total_sales'.



The SQL statement we are interested in is the same as the one in our original example, SELECT SUM(AMOUNT_SOLD) FROM SALES WHERE CUST_ID = :B1. We need to know the SQL_ID of this SQL statement to set up the trace, and we can find in V$SQL.


We now have everything we need to generate the trace.


Finally  you would look in the USER_DUMP_DEST directory for the trace file with the name you specified.

 

출처 : https://blogs.oracle.com/optimizer/entry/how_do_i_capture_a

No. Subject Author Date Views
Notice Guru's Article 게시판 용도 ecrossoug 2015.11.18 608
44 Explain the Explain Plan: Join Methods 명품관 2021.02.10 749
43 Explain the Explain Plan: Access Methods 명품관 2021.02.10 960
42 Explain the Explain Plan: Cardinality Estimates 명품관 2021.02.09 618
41 Explaining the Explain Plan – How to Read and Interpret Execution Plans 명품관 2021.02.09 492
40 SQL Window Functions Cheat Sheet 명품관 2020.05.26 440
39 SQL Tuning Workshop 명품관 2020.02.20 8158
38 New initialization parameters, data dictionary views & dynamic performance views in Oracle Database 19c 명품관 2019.02.08 1913
37 More New Features in Oracle Database 19c 명품관 2019.02.08 6593
36 New Features of Performance Tuning in Oracle Database 19c 명품관 2019.02.08 918
35 New Features of RAC & ASM in Oracle 19c 명품관 2019.02.08 953
34 New Features of Data Guard in Oracle Database 19c 명품관 2019.02.08 2004
33 New Features of Security in Oracle Database 19c 명품관 2019.02.08 5049
32 Patch conflicts 명품관 2019.02.07 974
31 New Features in Oracle Multitenant 19c 명품관 2019.02.07 744
30 New Features of Backup & Recovery in Oracle Database 19c 명품관 2019.02.07 432
29 New Features in Oracle Database 19c 명품관 2019.02.02 544
28 Different MOS Notes for xTTS PERL scripts – Use V4 scripts 명품관 2019.01.29 531
27 V$EVENT_NAME 뷰의 Name 컬럼에 정의된 event name에서 오는 오해 명품관 2017.03.08 371
26 Can I apply a BP on top of a PSU? Or vice versa? 명품관 2016.06.01 398
25 How to change the database name in 12c 명품관 2016.05.31 1994
Up