Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Huge performance difference between stored proc and anonymous PL/SQL block. Why?

user1585034Sep 13 2014 — edited Sep 14 2014

Hi!  I've searched various online resources and have been unable to find any that addressed this particular problem, so I'm hoping someone here may be able to offer some advice.

I have a stored procedure that is about 300 lines long, takes no parameters, and defines one record type and a few table types internally.  When I run it on a particular data set, it takes about 50 seconds to finish in my environment.  Unfortunately, it will have to be executed as an anonymous PL/SQL block rather than a stored procedure, due to policies that exist regarding the environment to which I'm deploying.  However, when I converted it to an anonymous PL/SQL block, making no other code changes whatsoever and running it from the same schema that owned the stored procedure, it takes about 6.5 minutes (nearly 8 times as long) to complete.  Aside from the parsing and validation overhead, which could add a fraction of a second, can anyone please suggest some potential reasons for the large performance difference, and offer advice on what I may be able to do about it?  In case it matters, the procedure uses bulk binds (e.g., bulk collect, forall) where it seems to make sense, and does not call any other PL/SQL objects.  Thanks in advance.

This post has been answered by Biju Das on Sep 13 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 12 2014
Added on Sep 13 2014
10 comments
3,009 views