Skip to Main Content
  • Questions
  • Measuring stored procedure with AUTOTRACE ON? (followup question)

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Chris.

Asked: February 15, 2017 - 8:07 am UTC

Last updated: February 15, 2017 - 1:41 pm UTC

Version: 11.2.0.3

Viewed 1000+ times

You Asked

Hi Team,

I posted a question regarding dynamic update SP earlier last week:
https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:9533310000346559369

And as a result of that, I have 2 versions of Stored Procedure for each SP i'm modifying. One is using EXECUTE IMMEDIATE and second using DBMS_SQL method. As the SP changes are almost finished (5 SP in total), we are thinking of the best way to test the performance and to figure out which version would use the least amount of database resource.

From searching around the web, I stumble on AUTOTRACE and seems this would be a good way to measure the SP. However i tried the below pl/sql and no result is showing.

SQL> 
SQL> set autotrace on
SQL> Begin
  2    FOR x in 1..1000 LOOP
  3      SP_CRM_UPDATE_SERVICE(x);
  4    END LOOP;
  5  END;
SQL> --result not displayed
SQL> 


Any other things i should look out for?

Best Regards,
Chris Tarjono

and Chris said...

Yeah, autotrace doesn't show the stats for the contents of your PL/SQL procedure.

Instead, you can trace your session. The trace file will contain details of the SQL execution. You can parse it to something more readable using tkprof. You can find instructions on how to do this at:

https://blogs.oracle.com/sql/entry/how_to_create_an_execution#tkprof

If you want to capture stats about the PL/SQL too, check out the hierarchical profiler:

https://docs.oracle.com/cd/B28359_01/appdev.111/b28424/adfns_profiler.htm#CHDBCIDI
https://oracle-base.com/articles/11g/plsql-hierarchical-profiler-11gr1

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library