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 > Execution time of a SQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-27-10, 12:04
surbhi_gt1 surbhi_gt1 is offline
Registered User
 
Join Date: Apr 2009
Posts: 11
Execution time of a SQL

With the help of db2advis I found out that on one query we should have 2 indexes:


I would like to create those indexes and would like to show to the application team that after making the indexes the query will take less time.
I would like to get the execution time before creating indexes and after creating indexes.

How should I do it?
Reply With Quote
  #2 (permalink)  
Old 01-27-10, 12:52
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Which DB2 version and OS?

Andy
Reply With Quote
  #3 (permalink)  
Old 01-27-10, 13:01
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Use the db2batch utility. It allows you to run a sample workload, possibly with varying parameters, and reports execution time summary. You will find more details in the manual.
Reply With Quote
  #4 (permalink)  
Old 01-27-10, 14:56
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
explain shows a number of timerons and if indexes were used. you can compare the timeron values before and after to prove that there is a performance improvement and indexes were used.
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
Reply With Quote
  #5 (permalink)  
Old 01-27-10, 15:09
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by MarkhamDBA View Post
the timeron values before and after to prove
Unfortunately, this is a common misconception. Cost estimate does not prove anything; it indicates that there might be a possible performance improvement, from the optimizer point of view. It may or may not reflect the actual change in query performance.

Only by running the actual workload on the actual system you can prove to yourself and to others that query performance has improved.
Reply With Quote
  #6 (permalink)  
Old 01-27-10, 15:42
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
and if you don't current statistics, you may not get any benefits from additional indexes because DB2 doesn't know how selective they may be
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #7 (permalink)  
Old 01-27-10, 23:34
surbhi_gt1 surbhi_gt1 is offline
Registered User
 
Join Date: Apr 2009
Posts: 11
I am using DB2 9.1 FP4 on Solaris.
Reply With Quote
  #8 (permalink)  
Old 01-28-10, 15:17
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
How many indexes do you already have? Do you need all of them? Are your stats upto date? How big is the table and is it partitioned or not? Just because you were told to build indexes , does not mean you have to.
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #9 (permalink)  
Old 01-28-10, 23:42
surbhi_gt1 surbhi_gt1 is offline
Registered User
 
Join Date: Apr 2009
Posts: 11
We have one indexes already existing which db2advis shows that we should drop it as it is unused. Table has approximately 1250000 rows. The table is not partitioned. Statistics are updated every week.
Reply With Quote
  #10 (permalink)  
Old 01-29-10, 09:12
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
set up db2pd to capture information on index usage to verify that that index is not used for sure before you drop it.

Is this SQL a one time deal or it is going to be run on the regular basis? If later, then you might want to create it.

How many tables are joined in your SQL? Are they joined correctly?
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
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