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 > db2 optimizer is taking inappropriate index

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-14-09, 13:27
dharmaraj_ganesan dharmaraj_ganesan is offline
Registered User
 
Join Date: Aug 2008
Posts: 23
db2 optimizer is taking inappropriate index

Hi,

We have one query running for hours and not completing. After analyzing we found one index(eg: Index1) was culprit, after dropping that index query ran within 15 mins(using another index eg: Index2).

But we cannot permanently remove Index1, as it is required for few other queries.

So is there any way for us to make the query always use Index2.

We tried reorg by choosing Index2, but also no effect.

Any suggestions are welcome!!!!

Thanks,
Dharmaraj.G
Reply With Quote
  #2 (permalink)  
Old 05-14-09, 15:09
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 05-14-09, 15:10
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
I am not sure but you can try

- to use design/index advisor on this query and see what it says;
- if a query is in a package you can try to change optimization level when you bind your package and it might change the indexes it is using;

my 5 cents
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
Reply With Quote
  #4 (permalink)  
Old 05-14-09, 15:40
dharmaraj_ganesan dharmaraj_ganesan is offline
Registered User
 
Join Date: Aug 2008
Posts: 23
@ Andy

DB2 version is 8.1 fixpack 12
OS version is AIX 5.3

@Markham

The query is not from package, it is a dynamic query and index advisor didnt help us...
Reply With Quote
  #5 (permalink)  
Old 05-14-09, 15:54
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You can try to use the SELECTIVITY clause:

DB2 Universal Database

Andy
Reply With Quote
  #6 (permalink)  
Old 05-14-09, 16:09
dharmaraj_ganesan dharmaraj_ganesan is offline
Registered User
 
Join Date: Aug 2008
Posts: 23
Thanks for your reply. I am going through SELECTIVITY clause.

Will execute and get back!!
Reply With Quote
  #7 (permalink)  
Old 05-16-09, 05:02
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You can also play with the statistics for both indexes. (Which raises the question whether your statistics are up to date in the first place.)
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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