Why can an index on created_at not be used by WHERE YEAR(created_at) = 2024?
- A Because dates cannot be indexed
- B Because wrapping the column in a function prevents index use
- C Because YEAR is not a valid function
- D Because the index must be a primary key
Answer
Because wrapping the column in a function prevents index use
Applying a function to the column means the stored index values no longer match the comparison. Rewriting as a date range keeps the index usable.





