Menu

SARGable Queries in SQL Server: Why Functions in WHERE Slow You Down
📰

SARGable Queries in SQL Server: Why Functions in WHERE Slow You Down

DEV Community·LingamSuyambu·13 days ago
#okPHyvWC
#dev#index#sargable#column#article
Reading 0:00
15s threshold

Originally published at SQL & Cloud Lab .

You add the perfect index, run the query, and SQL Server still scans the whole table. One of the most common reasons is a non-SARGable predicate: a WHERE clause written in a way that stops SQL Server from using the index to seek. The fix is usually a small rewrite.

What SARGable means

SARGable stands for Search ARGument-able . A predicate is SARGable when SQL Server can use it to jump straight to the matching rows in an index (an index seek). If you wrap the indexed column in a function or calculation, SQL Server can no longer search the index for a value; it has to calculate the expression for every row, which means a scan.

The rule of thumb: leave the column bare on one side of the comparison, and do any calculation on the other side.

Common non-SARGable patterns and their fixes

Functions on date columns

-- Not SARGable: YEAR() runs on every row WHERE YEAR ( OrderDate ) = 2026

-- SARGable: a range on the bare column WHERE OrderDate >= '2026-01-01' AND…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.