SQL Server Interview Question #135
What is a SARGable query?
Indexes & Query Performance Senior Advanced
Detailed Explanation
SARGable means a predicate can be used effectively as a search argument by an index. SARGable predicates often allow SQL Server to seek into an index rather than evaluate a function or expression for many rows.
Applying a function to an indexed column can make a predicate non-SARGable. Rewriting the condition as a range often improves index usability.
Code Example
-- Less SARGable:
SELECT *
FROM dbo.Orders
WHERE YEAR(OrderDate) = 2026;
-- More SARGable:
SELECT *
FROM dbo.Orders
WHERE OrderDate >= '2026-01-01'
AND OrderDate < '2027-01-01';