Indexes and performance
SARGability and implicit conversion
Write predicates an index can use.
Understand the concept
A SARGable predicate allows an access path to use search boundaries. A date range is generally a better candidate than YEAR(OrderDate) = 2026. It does not guarantee a seek: statistics, selectivity and cost still matter.
Functions or type conversion on an indexed column can reduce access options. Parameter/column mismatches can introduce implicit conversion; which side converts matters. A prefix LIKE pattern can sometimes become a range, while a leading wildcard generally cannot provide the same B-tree advantage. Do not break collation, language or business semantics just to alter a plan.
Make filtering both correct and measurable.
Promising a speedup merely because a function was removed.
One topic. Three levels of depth.
SELECT OrderId FROM lab.SalesOrder WHERE OrderDate >= '20260101' AND OrderDate < '20270101';Bounds the year without transforming the column.
This page does not execute SQL. Practise in the downloadable SqlStudioLab using SSMS. Before rerunning temporary-table examples, remove only the relevant #table. Views, procedures and functions create persistent lab objects; never use a production connection.
Try it yourself first.
Filter February orders without YEAR or MONTH.
Show the solution and explanation
SELECT OrderId FROM lab.SalesOrder WHERE OrderDate >= '20260201' AND OrderDate < '20260301';Returns 103, 104 and 105; March 1 is excluded.