DBMS Profiler
DBMS Profiler
put_line statements
to display variable states. But advanced PL/SQL can be problematic. The display components of
PL/SQL (dbms_output and utl_file) provide limited PL/SQL debugging capabilities.
2. dbms_debug Utility – It is a useful programming utility for PL/SQL Developers.
3. Use dbms_profiler - The dbms_profiler package can aid in PL/SQL debugging.
4. Conditional Compilation - In Oracle10g, PL/SQL conditional compilation is ideal for debugging
PL/SQL
5. PL/SQL debugger - You can use Oracle's PL/SQL debugger (part of the free SQL Developer suite)
to step through the PL/SQL code, one line at a time, and find any error:
Note:- dbms_profiler is to PL/SQL, what tkprof and Explain Plan are to SQL.
The dbms_profiler package is a built-in set of procedures to capture performance information from
PL/SQL. It gathers information at the PLSQL virtual machine level. Ex- total number of times each line
has executed and amount of time spent on executing that line. Also min and max time that have been
spent on a particular execution of that line.
PLSQL_PROFILER_UNITS – Holds details of each unit that run during a profiler run.
PLSQL_PROFILER_DATA – Execution statistics for each line of code contained in the PLSQL code.
dbms_profiler.start_profiler
dbms_profiler.flush_data
dbms_profiler.stop_profiler
The profiler does not begin capturing performance information until the call to start_profiler is
executed.
The flush command enables the developer to dump statistics during program execution without
stopping the profiling utility. The only other time Oracle saves data to the underlying tables is when
the profiling session is stopped, as shown below:
Once the developer stops the profiler, all the remaining (unflushed) data is loaded into the profiler
tables.
a.run_total_time/1000000000 Tot_run_secs,
a.run_owner
WHERE a.runid =b.runid AND a.runid =c.runid AND b.unit_name=u.name AND c.line# =u.line;
The basic idea behind profiling with dbms_profiler is for the developer to understand where their code
is spending the most time, so they can detect and optimize it. The profiling utility allows Oracle to
collect data in memory structures and then dumps it into tables as application code is executed.
dbms_profiler is to PL/SQL, what tkprof and Explain Plan are to SQL.
Once you have run the profiler, Oracle will place the results inside the dbms_profiler tables.
The dbms_profiler procedures are not a part of the base installation of Oracle. Two tables need to be
installed along with the Oracle supplied PL/SQL package. In the $ORACLE_HOME/rdbms/admin
directory, two files exist that create the environment needed for the profiler to execute.