Documente Academic
Documente Profesional
Documente Cultură
Live 2004
Quick Tip #10:
Tuning PL/SQL procedures
using DBMS_PROFILER
Tim Gorman
Principal - SageLogix, Inc.
Email: tim@sagelogix.com
www.SageLogix.Com
Agenda
• Overview of tuning tools in Oracle
– Tuning SQL
– SQL Trace
–TKPROF
–Oracle Trace Analyzer
–Hotsos Profiler (www.hotsos.com)
–UB Tools Analyzer (www.ubtools.com)
– Tuning PL/SQL
– DBMS_PROFILER
Overview of performance tuning
– Is it waiting on something?
– If so, what exactly is it waiting for?
SQL*Net
message from
client (wait)
CPU (service)
User db file
sequential read
Response (wait)
Time CPU (service)
SQL*Net
message from
client (wait)
Measuring time
• Tracing
– Tracing is the recording of actions performed by a
program, as they are performed
• Oracle SQL tracing
– Event 10046
– alter session set events ‘10046 trace name context
forever, level 8’
– exec dbms_support.start_trace
– New book “Optimizing Oracle Performance” by Cary
Millsap and Jeff Holt (O’Reilly & Associates, Sep 2003)
– ISBN #059600527X
Summarizing trace data
• Recording every action performed by a program
generates huge volumes of data to analyze
– Forest and trees
– Look at the trees for diagnosing failures
– Look at the forest to tune performance
• Application profiling
– “C” programs: UNIX “prof”
– Java programs: EJP on http://www.sourceforge.net
– Commercial products from http://www.semdesigns.com
– profilers for Java, C#, C++, C, COBOL, other languages
– TKPROF for SQL trace data
• Profiling is the summarization of trace data
Profiling
0
DBMS_PROFILER
2
Using DBMS_PROFILER
• Initial setup:
– DBMS_PROFILER package has been created by
the DBA using “profload.sql”…
– developer/user has created the tables using
“proftab.sql”
• Add profiler procedures to PL/SQL source
– Procedure START_PROFILER(‘run-comment’)
– Procedure STOP_PROFILER
• Recompile and run the procedure
3
Using DBMS_PROFILER
4
Case Study #1
5
Case Study #1
• Files:
– proftest1.sql
– DDL to create stored procedure and table
–Including use of DBMS_PROFILER
– run_proftest1.sql
– SQL*Plus script to run the test
– proftest1.tkp
– Output from tkprof <trc-file> <tkp-file>
sort=prsela,exeela,fchela explain=<un>/<pwd>
– proftest1_18.html
– proftest1_19.html
6
Case Study #1
7
Case Study #2
8
Case Study #2
9
Quick Tip #Q10
Q&A
Email: tim@sagelogix.com
0