All Questions
Database Indexing medium

Why does `WHERE YEAR(created_at) = 2023` fail to use a standard index on `created_at`?

  1. A SQL functions are executed on the client application side, which prevents the database engine from ever seeing the resulting computed values.
  2. B The B-Tree indexes raw values; applying a function 'hides' the data from the index's sort order, forcing the database to perform a full table scan.
  3. C Temporal data types like 'Date' and 'Timestamp' are fundamentally incompatible with B-Tree indices and must utilize specialized R-Tree structures.
  4. D The query automatically triggers a 'Composite Index' scan that defaults to the leftmost column regardless of the filtering predicate provided.

One system design question a day, with spaced repetition so the ones you miss come back.

Get the app

Related questions