Indexes & Performance · SQL SQL

Which of the following scenarios is most likely to result in an index being ignored by the query optimizer during a SELECT query with a WHERE clause?

Practice question from Indexes & Performance (SQL SQL), with the correct answer and a step-by-step solution.

medium · MCQ · Q-A1B2F6

Which of the following scenarios is most likely to result in an index being ignored by the query optimizer during a SELECT query with a WHERE clause?

  1. A.Using an equality operator like WHERE id = 100
  2. B.Applying a deterministic function or expression directly to the indexed column, such as WHERE UPPER(email) = '[email protected]'Correct answer
  3. C.Sorting the results using ORDER BY on the leading column of the index
  4. D.Performing an inner join on an indexed foreign key column

Solution

Wrapping an indexed column in a function like UPPER() alters the stored values, making standard B-tree indexes unusable unless a functional/expression index has been explicitly created.

More from Indexes & Performance

All of Indexes & Performance

Practise more SQL

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed