I have encountered a very weird problem. I have two tables . the only difference between the two tables is one column which exists on the T1 table has been ommitted from the second table T2. Then I took the data out from the first table and bcp'ed them into T2 via sqsh. All the indexes are still the same. Now, one query with T1 table is faster than the same query when T2 is used instead of T1.
is faster than
Now, when I saw the query plan they were different, the indexes used by the optimizer is different. What I donot understand is, the first query is using the index on col3 but the second query is not using the index on col3 because it thinks it's better off using the index on col2??? And this difference is making the second query run slower. What should I do in such a case??? Please help!!!!!!!!!!!!!!!