What does SARGable mean, and why does it matter?
Quick Answer
SARGable (“Search ARGument able”) means a predicate can use an index seek. Wrapping the column in a function (YEAR(OrderDate) = 2026), applying arithmetic to it, using a leading % in LIKE, or forcing an implicit type conversion all make a predicate non-SARGable, so the engine must scan.
SARGable means the predicate is written in a way that lets SQL Server seek an index. The moment you put a function around the column — YEAR(OrderDate) = 2026, UPPER(name) = ..., arithmetic on the column, or a LIKE with a leading wildcard — it can't seek any more and has to scan and evaluate every row. So I rewrite those: the year example becomes a date range, >= Jan 1 and < Jan 1 next year. The sneaky one is implicit conversion — an nvarchar column compared to a varchar parameter converts the whole column.
- Non-SARGable → SARGable rewrites:
YEAR(d) = 2026→d >= '2026-01-01' AND d < '2027-01-01'ISNULL(status,0) = 0→status = 0 OR status IS NULLcol * 2 > 100→col > 50LIKE '%abc'→ can't seek; consider a computed reversed column or full-text
- Implicit conversion: comparing an
NVARCHARcolumn to aVARCHARparameter (or vice versa) can convert the whole column and kill the seek — match the parameter type.