Siva Academy

Youtube.com/SivaAcademy  Oracle SQL  |  PLSQL  |  SQL PLSQL Interview Questions  |  PLSQL Scenario based Interview Questions  |  Subscriber Questions & Answers

  |  SQL practical Question  |  SQL Performance Tuning  |  New Features  |  

  Trigger     |    View  

Saturday, June 8, 2019

profile PLSQL code using DBMS_PROFILER


Create the profiler tables from the table creation script available in oracle home directory

@C:\orclee18c\WINDOWS.X64_180000_db_home_ORACLE18C\rdbms\admin\proftab.sql

** Search for "proftab.sql" in your oracle home directory



Scripts to clear the profiler tables

truncate table plsql_profiler_data;
delete from plsql_profiler_units;
delete from plsql_profiler_runs;


Invoke "dbms_profiler.start_profiler" to start the profiler and "dbms_profiler.stop_profiler" to stop the profiler.Sample code give below,

exec dbms_profiler.start_profiler ('MY_TEST_PERFORMANCE_RUN1');
exec proc_a;
exec dbms_profiler.stop_profiler();



Query to find the line wise time taken

SELECT
plsql_profiler_runs.RUN_DATE, 
plsql_profiler_runs.RUN_COMMENT,
plsql_profiler_units.UNIT_TYPE, 
plsql_profiler_units.UNIT_NAME,
plsql_profiler_data.LINE#, 
plsql_profiler_data.TOTAL_OCCUR, 
plsql_profiler_data.TOTAL_TIME, 
plsql_profiler_data.MIN_TIME, 
plsql_profiler_data.MAX_TIME,
round(plsql_profiler_data.total_time/1000000000) total_time_in_sec,
trunc(((plsql_profiler_data.total_time)/(sum(plsql_profiler_data.total_time) over()))*100,2) pct_of_time_taken
FROM
    plsql_profiler_data,plsql_profiler_runs,plsql_profiler_units
where plsql_profiler_data.total_time > 0 
and plsql_profiler_data.runid = plsql_profiler_runs.runid
and plsql_profiler_units.UNIT_NUMBER = plsql_profiler_data.UNIT_NUMBER
and plsql_profiler_units.runid = plsql_profiler_runs.runid
ORDER BY
    plsql_profiler_data.total_time DESC;

15 comments:

  1. very clear explanation .keep going.

    ReplyDelete
  2. Thank you for posting hand on queries here keep going your good work

    ReplyDelete
  3. Very good explanation.Thanks Siva.

    ReplyDelete
  4. Hi .. Its great to learn with great explanation. Can we have video of detailed explanation of how to analyze explain plan and AWR report step by step for performance issues. Really appreciate for all these.

    ReplyDelete
  5. how can i tune plsql code while its running and i have no control over it ?

    ReplyDelete
  6. Excellent explanation for Exp people

    ReplyDelete
  7. Excellent explanation. looking forward to see more videos related to PT.

    Thanks in Advance

    ReplyDelete
  8. Sir, your are my Guru for PLSQL. Keep rocking

    ReplyDelete
  9. Hi siva,
    Really good explanation.

    ReplyDelete
  10. Very very excellent teaching methodology.
    I wish I had found this site earlier.

    ReplyDelete
  11. I follow your channel regularly. This is one of the best I've come across for practical solutions. Keep helping us with your guidance, it helps.

    ReplyDelete