SQL & Relational Databases (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
What is SARGability (Search Argument Able) in SQL queries?
senior LevelDatabases & SQL
In Simple Words: A query is SARGable if the optimizer can leverage an index range seek:
- Non-SARGable (Bad): Wrapping indexed columns in functions disables the index!
WHERE YEAR(created_at) = 2026;(forces full table scan on 10 million rows). - SARGable (Good): Keep the column naked:
WHERE created_at >= '2026-01-01' AND created_at < '2027-01-01';(executes fast B-Tree index seek).