Forcing the use of an index can improve performance?

Posted by aF. on Stack Overflow See other posts from Stack Overflow or by aF.
Published on 2012-08-29T15:37:07Z Indexed on 2012/08/29 15:38 UTC
Read the original article Hit count: 134

Filed under:
|

Imagine that we have a query like this:

select a.col1, b.col2
from t1 a
inner join t2 b on a.col1 = b.col2
where a.col1 = 'abc'

Both col1 and col2 don't have any index.


If I add another restriction on the where clause, one that is always correct but with a column with an index:

select a.col1, b.col2
from t1 a
inner join t2 b on a.col1 = b.col2
where a.col1 = 'abc'
and a.id >= 0  -- column always true and with index

May the query perform faster since it may use the index on id column?

© Stack Overflow or respective owner

Related posts about sql

Related posts about tsql