Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Morgan.

Asked: December 02, 2015 - 3:09 pm UTC

Last updated: November 30, 2018 - 6:17 am UTC

Version: 11.2.0.3

Viewed 10K+ times! This question is

You Asked

We are using StreamServe ( http://www.opentext.com/what-we-do/products/customer-experience-management/customer-communications-management/opentext-streamserve ) to print documents from our database.

This application gives us a severe headache because it eats up SGA when there are lots of users (thousands). A bit of detective work has shown me that they use EXECUTE IMMEDIATE to select from metadata-tables containing approx 1000 lines of data. Not so much.

Now, my conclusion is that we have lots of parsing here on one query - SELECT archive_table FROM archive_field_mapping, metadataname WHERE archive_field_mapping.metadatanameid = metadataname.metadatanameid AND rownum < 2 AND archive_field_mapping.typeid = :1.

I do not have the source code of StreamServe but one might think that they are using bind variables so heavy parsing should not be the case? Is there a difference in using EXECUTE IMMEDIATE, would DBMS_SQL be a better choice here? I know that they are using EXECUTE IMMEDIATE, their support has told me so.


Morgan

and Connor said...

Well that query should be sharable, so those parses should ultimately be soft parses. Still not great, but better than a hard parse.

You can check session/system systems for difference between parse count and hard parse count to confirm.

But if their software is explcitly doing a parse call, then there is not much we can do about it.

The obvious question for the vendor - if they are running what appears to be a static SQL, why the dynamic SQL at all ?


Rating

  (1 rating)

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

Comments

which one is better

krishnarjun rao, November 29, 2018 - 1:54 pm UTC

hi Tom,
My main question is which one is better -
execute immediate
or
dbms_sql

Since execute immediate is new one and intuitive I think
it is better than old dbms_sql. Please clarify my doubt.
Thanks in advance.
Connor McDonald
November 30, 2018 - 6:17 am UTC

Not a case of "better" but "different".

My mantra generally is:

If I can get away with 'execute immediate' I will do so. The code is typically cleaner and easier for the next person who comes along to mantain it.

But there are some things that it can't do - like manage an unknown number of bind variables at compilation time. For things like that, I'll fall back to dbms_sql

More to Explore

DBMS_SQL

More on PL/SQL routine DBMS_SQL here