|
What does SARGable mean? I see this posted in forums.
(comments are locked)
|
|
I've read the article on Wikipedia before. I don't think it's entirely accurate. What does the use of a covering index have to do with SARGable? Anyway, it's a measure of whether or not the query can use an index. Specifically, whether or not predicates in WHERE clauses and JOIN clauses will prevent the use of an index. There are operators that are SARGable and ones that are not. SARGable operations would include =,>,<, BETWEEN, and some LIKE conditions. Non-SARGable operations would include <>,!=,NOT IN, OR, other LIKE conditions. The use of a function on a column can render the query Non-SARGable as well. Can I ask where the != operator not being SARGable comes from? If I have two queries reading a table by it's clustered index using = or !=, the plans show as equivalent for me...
Oct 10 '09 at 11:00 AM
Matt Whitfield ♦♦
I believe the issue of != comes from the optimizer not using an index when it was included. This was the behavior for years, so every query with a != caused a scan. Regardless of logic, if it doesn't get the optimizer to use an index, then it isn't SARG-able.
Oct 12 '09 at 10:52 AM
Steve Jones - Editor ♦♦
(comments are locked)
|
|
According to Wikipedia:
(comments are locked)
|

