Db2curiosity
Programmer
Hi,
we are doing the 2 following updates in DB2 8.1,the index meant for 1st update is getting used in 2nd update and making it very slow.
** Table c has 7MM rows.
** Table w has 300K records.
** RUN STATS are Current for both tables.
** REORGCHK on table c has been done and it looks ok
/** For Query1 we have a nonunique comp index INDEX1 on source,key1,key3,key9,col4 which is making it run very Fast**/
UPDATE Table1 c
SET c.col1 = 1
,c.COL2 = 2
,c.COL3 = CURRENT_TIMESTAMP
WHERE c.COL4 = 4
AND EXISTS (SELECT 1 FROM temp_table w
WHERE w.source = c.source
and c.source = 'SIEBEL'
and c.key1 = w.key1
and c.key3 = w.key3
and c.key9 = w.key9 )
/** For Query2 we have a nonunique comp index INDEX2 on source,key1,key2,key4,key6,col4 ***/
But the following query is not picking INDEX2( as per db2expln) , rather its picking up INDEX1 above running forever.
Interesting is that when i drop INDEX1 , the Query2 picks up INDEX2 and runs very fast ...
But that's not a solution because when i drop INDEX1 the Query1 becomes slow which is natural.
UPDATE Table1 c
SET c.col1 = 1
,c.COL2 = 2
,c.COL3 = CURRENT_TIMESTAMP
WHERE c.COL4 = 4
AND EXISTS (SELECT 1 FROM temp_table w
WHERE w.source = c.source
and c.source = 'SIEBEL'
and c.key1 = w.key1
and c.key2 = w.key2
and c.key4 = w.key4
and c.key6 = w.key6 )
** I tried building a single index INDEX3 which can take care both queries
(source,key1,key2,key3,key4,key6,key9,col4)
and dropped both INDEX1 and INDEX2 but that's not helping either.
** DB2 doesn't support SQL HINT like Oracle does so that i can tell the 2nd query to use INDEX2 instead of INDEX1 because that's for someone else.
Please help... I'm stuck in a very wierd situation.
we are doing the 2 following updates in DB2 8.1,the index meant for 1st update is getting used in 2nd update and making it very slow.
** Table c has 7MM rows.
** Table w has 300K records.
** RUN STATS are Current for both tables.
** REORGCHK on table c has been done and it looks ok
/** For Query1 we have a nonunique comp index INDEX1 on source,key1,key3,key9,col4 which is making it run very Fast**/
UPDATE Table1 c
SET c.col1 = 1
,c.COL2 = 2
,c.COL3 = CURRENT_TIMESTAMP
WHERE c.COL4 = 4
AND EXISTS (SELECT 1 FROM temp_table w
WHERE w.source = c.source
and c.source = 'SIEBEL'
and c.key1 = w.key1
and c.key3 = w.key3
and c.key9 = w.key9 )
/** For Query2 we have a nonunique comp index INDEX2 on source,key1,key2,key4,key6,col4 ***/
But the following query is not picking INDEX2( as per db2expln) , rather its picking up INDEX1 above running forever.
Interesting is that when i drop INDEX1 , the Query2 picks up INDEX2 and runs very fast ...
But that's not a solution because when i drop INDEX1 the Query1 becomes slow which is natural.
UPDATE Table1 c
SET c.col1 = 1
,c.COL2 = 2
,c.COL3 = CURRENT_TIMESTAMP
WHERE c.COL4 = 4
AND EXISTS (SELECT 1 FROM temp_table w
WHERE w.source = c.source
and c.source = 'SIEBEL'
and c.key1 = w.key1
and c.key2 = w.key2
and c.key4 = w.key4
and c.key6 = w.key6 )
** I tried building a single index INDEX3 which can take care both queries
(source,key1,key2,key3,key4,key6,key9,col4)
and dropped both INDEX1 and INDEX2 but that's not helping either.
** DB2 doesn't support SQL HINT like Oracle does so that i can tell the 2nd query to use INDEX2 instead of INDEX1 because that's for someone else.
Please help... I'm stuck in a very wierd situation.