Mid
Performance
SQL & Databases
How do you write a sargable date filter?
Short answer: Do not wrap the column: avoid WHERE YEAR(OrderDate)=2025. Use a range filter such as OrderDate >= '2025-01-01' AND OrderDate < '2026-01-01' so an index can be used.
Sargable = search argument able — keep functions on the constant side.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png