If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Analysing execution times in Control Center

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-28-11, 02:03
olel olel is offline
Registered User
 
Join Date: Oct 2009
Posts: 23
Analysing execution times in Control Center

Hi all,

we are trying to do some performance optimizations in our application and are therefore analyzing some slow SQL statements.

We are using the tool DB2 Monitor (IBM DB2 UDB Performance monitor) for grabbing the long running SQLs.

Yesterday I found a statement which execution time was 12 seconds (measured by our application itself and by DB2 Monitor). I copied the statement and put it into the DB2 Control Center application in order to let it build the execution plan so that I can find the most expensive parts of the statement. But when I execute this same statement in the Control Center it only takes 0.5 seconds. How is that?

In order to exclude any caching issues I re-executed the statement several times in our application and in the Control Center and each time it took 12 seconds in the app and 0.5 seconds in the Control Center.

Can someone explain to me what I am doing wrong? That way I am unable to find my performance leaks.

Thanks in advance,
Olel

DB2 version: "DB2 v9.1.300.257", "s070719", "WR21393" and FixPak "3".
DB2 type: DB2 Enterprise Server Edition, db2ese, 9.1

Last edited by olel; 10-28-11 at 02:06. Reason: added version and type
Reply With Quote
  #2 (permalink)  
Old 10-28-11, 08:26
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by olel View Post
Can someone explain to me what I am doing wrong?
I bet my shoes that you're substituting literal values for parameter markers in the WHERE clause. Don't do it; use EXPLAIN PLAN FOR SELECT ... to generate explain information for the original statement.
Reply With Quote
  #3 (permalink)  
Old 10-28-11, 09:03
olel olel is offline
Registered User
 
Join Date: Oct 2009
Posts: 23
Not bad... you're right! Looks like this is a common mistake by newbies...
As I am such a newbie can you explain how that "EXLAIN PLAN FOR SELECT" works? I would like to stick to the graphical representation of the plan which is part of the Control Center as I am not really good in reading textual explain plans.

Oh, and why is the query is so much faster with literal values?

Thanks in advance!
Reply With Quote
  #4 (permalink)  
Old 10-28-11, 09:26
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You can still use the Control Center/Command Editor to get the visual explain using parameter markers. In the Command Editor, enter the SQL with parameter markers. Then press the "Access Plan" button.

Andy
Reply With Quote
  #5 (permalink)  
Old 10-28-11, 11:06
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by olel View Post

Oh, and why is the query is so much faster with literal values?
See if this thread answers your question. Prepared statement not using indexes
Reply With Quote
  #6 (permalink)  
Old 10-29-11, 16:42
olel olel is offline
Registered User
 
Join Date: Oct 2009
Posts: 23
Quote:
Originally Posted by n_i View Post
See if this thread answers your question. Prepared statement not using indexes
As far as I understand that thread there are some optimization possibilities for DB2 if you use literal values.

I think that makes clear why I cannot see any differences when executing queries directly in the Control Center with literal values with indexes created or not.

Is there any way to execute queries in the Control Center with literal values without giving DB2 the opportunity for these optimizations? It would be very helpful for me to test some queries with literal values without having our application running.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On