I understand that the order of criteria in the where clause does not influence index usage.
Does parenthesis influence the index usage in SQL Server? Is there any example?
I understand that the order of criteria in the where clause does not influence index usage.
Does parenthesis influence the index usage in SQL Server? Is there any example?
Obviously. If I have an index on (y)
and an expression like this:
where y > 10 and x = 'a' or x = 'c'
then no index will be used.
If I put:
where y > 10 and( x = 'a' or x = 'c')
Then the index will probably be used.
These do different things, but that is not part of your question. Parentheses can change the meaning of a SQL statement and that changes the use of indexes.