dbTalk Databases Forums  

DB2 v9.1 slow query with IN clause

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss DB2 v9.1 slow query with IN clause in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
harry
 
Posts: n/a

Default DB2 v9.1 slow query with IN clause - 10-07-2010 , 09:05 PM






Upgrading a database for a J2EE software product from v8.1 to v9.1. Cannot modify the query in vendor code. The optimization level is 5. The tables have been altered to volatile. The rootid are primary keys. I want the query issued from Java to use us_usertab(rootid) index, and the usertab(us_user) index. However it seems that due to the IN clause, the query is executed using the usertab(rootid) index instead. I did the runstats with distribution and all detailed indexes and all key columns. I even went as far as updating the cardinality to be very high, reorging the table around the indexed columns that I want to use, and still no effect. One thing I have not tried is to temporarily increase optimization level to 9. Certainly the application team does not like the idea of changing the optimization level.

Anything did I miss? I suspect some configuration parameter problems because this IN query should be simple enough for DB2 optimizer to analyze.

SELECT us_1.rootId FROM UserTab Use2 , us_UserTab us_1 WHERE (Use2.rootId LIKE '%.9m' OR Use2.rootId LIKE '%.2h' ) AND (Use2.us
_User = us_1.rootId AND us_1.rootId IN ('7x1n7yt.b7', 'tbsr.b7')) AND (Use2.us_Active = 1) AND (Use2.us_PurgeState = 0) AND (Use
2.us_PartitionNumber = 2) AND (us_1.cus_Active = 1) AND (us_1.cus_PurgeState = 0) AND (us_1.cus_PartitionNumber = 0)

Reply With Quote
  #2  
Old   
Fabio
 
Posts: n/a

Default Re: DB2 v9.1 slow query with IN clause - 10-08-2010 , 12:42 AM






Il 08/10/2010 04:05, harry ha scritto:
Quote:
(Use2.rootId LIKE '%.9m' OR Use2.rootId LIKE '%.2h' )
Did you run an Explain on your query ?
IMHO the part (Use2.rootId LIKE '%.9m' OR Use2.rootId LIKE '%.2h' )
should be checked...
OR and LIKE toghether are no good for DB2 from an index point of view.

Bye
Fabio

Reply With Quote
  #3  
Old   
Hardy
 
Posts: n/a

Default Re: DB2 v9.1 slow query with IN clause - 10-08-2010 , 01:21 PM



On Oct 7, 9:05*pm, harry <u... (AT) compgroups (DOT) net/> wrote:
Quote:
Upgrading a database for a J2EE software product from v8.1 to v9.1. Cannot modify the query in vendor code. The optimization level is 5. The tables have been altered to volatile. The rootid are primary keys. I want the query issued from Java to use us_usertab(rootid) index, and the usertab(us_user) index. However it seems that due to the IN clause, the query is executed using the usertab(rootid) index instead. I did the runstats with distribution and all detailed indexes and all key columns. I even went as far as updating the cardinality to be very high, reorging the table around the indexedcolumns that I want to use, and still no effect. One thing I have not tried is to temporarily increase optimization level to 9. Certainly the application team does not like the idea of changing the optimization level.

Anything did I miss? I suspect some configuration parameter problems because this IN query should be simple enough for DB2 optimizer to analyze.

SELECT us_1.rootId FROM UserTab Use2 , us_UserTab us_1 WHERE (Use2.rootIdLIKE '%.9m' *OR Use2.rootId LIKE '%.2h' ) AND (Use2.us
_User = us_1.rootId AND us_1.rootId IN ('7x1n7yt.b7', 'tbsr.b7')) AND (Use2.us_Active = 1) AND (Use2.us_PurgeState = 0) AND (Use
2.us_PartitionNumber = 2) AND (us_1.cus_Active = 1) AND (us_1.cus_PurgeState = 0) AND (us_1.cus_PartitionNumber = 0)
do you want to try some composite key on these two tables?

Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.