|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Queryplan differs with simple valuesIm having a hard time finetuning my queries. Im using SQL2000 Enterprise with SP3. I've a table with approximately 500.000.000 rows in and for some strange reason I get different queryplans according to similar where clauses, take a look at this: The Table1 has 2 indexes: nonclustered index idx1 at founddate nonclustered index idx2 at founddate, traveldate, travelagent select founddate, traveldate, costprice, fareclass, travelagent from Table1 where founddate = 2500 and traveldate = 2600 and travelagent in('xxx', 'yyy') Then the query optimizer chooses the right index = idx2 using index seek But when I change the query to: select founddate, traveldate, costprice, fareclass, travelagent from Table1 where founddate = 2500 and traveldate = 2600 and travelagent in('xxx') It suddenly chooses idx1 with index seek and them uses a scan for the rest of the values. If I then just change the last where clause to and travelagent in('xxx', 'xxx') and then jumps back and uses idx2 again... Any suggestions? |
|||||||||||||||||||||||