Skip to main content

developerworkslabel >  Information Management  >  forumlabel  >  DB2 for z/OS forum  >  developerWorks

Benchmark    Point your RSS reader here for a feed of the latest messages in this thread


     

 
 

loginbox.header
 loginbox.welcomelabel loginbox.guestlabel
loginbox.signin
Permlink Replies: 3 - Pages: 1 - Last Post: Oct 29, 2009 4:53 PM Last Post By: Eric_Nolmans Threads: [ Previous | Next ]
Eric_Nolmans

Posts: 11
Registered: May 29, 2006 03:59:30 AM
Benchmark
Posted: Oct 23, 2009 05:49:09 AM
Click to report abuse...   Click to reply to this thread Reply
Hi,

I'm looking after benchmark comparing DYNAMIC SQL and STATIC SQL on DB2 V9 Z/OS.
We are running web application on websphere server 6.1. these applications are calling stored procedure but I want to know of there is a big difference in performance between static and dynamic.

Can someone tell me where I can found it?

thanks
Eric_Nolmans

Posts: 11
Registered: May 29, 2006 03:59:30 AM
Re: Benchmark
Posted: Oct 23, 2009 09:13:52 AM   in response to: Eric_Nolmans in response to: Eric_Nolmansthread.responsepost
Click to report abuse...   Click to reply to this thread Reply
if there is no benchmark, I'll be very please if someone can tell me what's the best solution when you write a java application.
What's the best practice using a dynamic sql or static sql statement?
n314890

Posts: 6
Registered: Apr 05, 2004 10:02:22 AM
Re: Benchmark
Posted: Oct 26, 2009 05:59:27 AM   in response to: Eric_Nolmans in response to: Eric_Nolmansthread.responsepost
Click to report abuse...   Click to reply to this thread Reply
Hi Eric,

I guess the reason you haven’t got any replay on your question is that the answer is “it depends”.

Historically, DB2 on z/OS have recommended static SQL but over the last couple of versions and the introduction of the statement cash and tools to look at it that have changed.

This is just to give you a flavour of the answer to your question. There is a lot more to consider.

Why use static SQL:

1)The access path is decided at bind time and if the statistics in the catalogue is “correct” the optimizer choose the best access path (mostly) for it.

2)You do not have any overhead of choosing the access path at execution time. This is important when we have SQL statements that need to be as quick as possible. E.g. ATM-machines transactions.

3)You easily check the chosen access path in the PLAN_TABLE

4)You do not need to run runstats (costly) that often to update the statistics in the catalogue.

Drawbacks of using static SQL:

1)You need to make sure that the chosen access path at bind is what you hade expected and performs well.

2)You probably end up with many SQL statements in your program when you have multiple predicates in the SQL. This to get good access paths for them. (no OR between predicates, no range predicates if not needed)

Why use dynamic SQL:

1)Give you flexibility in creating the SQL in the program. Gives you fewer statements to maintain but perhaps a more complex logic in the program.

2)Can take advantage of new catalogue statistics and changes access path to a better if the data have changed in size or pattern.

Drawbacks of using dynamic SQL:

1)You pay an extra cost (cpu & elapsed) for each SQL statement when the optimizer checks the access path for the SQL. This is not significant if the elapsed time for the SQL is long.

2)Less control of the access path that the SQL that have been using (requires that you use EXPLAIN YES at bind).

To address some of the disadvantages of dynamic SQL DB2 for Z introduced the statement cash. The statement cash hold the latest used SQL statements and the access path chosen for them. So this takes away the need for at mini bind the second time the same dynamic SQL will be executed. But be aware it needs to be exactly identical to the SQL in the cash. If not there will be a new mini bind.
If you need to change the value in the predicate you can use “place holders” for your variables. But I do not how you do that in Java. My coding skill froze at PL/I and Cobol back in the 80s and the us of static SQL.

Well, this post did not answer question but I hope I give you a favour of that each installation, application and so on have there unique environment and you have to evaluate the solution accordingly.
If you find any benchmarks you need to check how well the benchmark environment conforms to yours.

Regards, Christer J

Eric_Nolmans

Posts: 11
Registered: May 29, 2006 03:59:30 AM
Re: Benchmark
Posted: Oct 29, 2009 04:53:56 PM   in response to: n314890 in response to: n314890thread.responsepost
Click to report abuse...   Click to reply to this thread Reply
Hi Christer,

I’m very happy to read that someone has an answer to my question.
It’s very interesting point of view that you have.

In fact, I agree with you when you tell me “it depends”.
If I take a example of web application having an “search screen” with a lot of input fields, the best way to give a response to the user in short laps of time is to use ( I think) the dynamic sql with the prepare statement.
If I have a complex business, it’ll be easy for the developer to use dynamic sql. But what the customer is waiting is a fast answer and in this case, static sql is the best choice.

I think that the best way to find the best solution is to make some tests on our machine.

Regards,

Eric
 Tags
Help

Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular type of content or application that you're viewing.

My tags shows your tags for this particular type of content or application that you're viewing.

 

MoreLess 


Point your RSS reader here for a feed of the latest messages in all forums