Databases · Middle · Question 2 of 75
There's an index on (last_name, first_name). Which query can use it efficiently?
- 1Neither: a two-column index works only when both columns are in
WHERE - 2
WHERE first_name = 'Ann' - ✓Correct answer:
WHERE last_name = 'Smith'
Explanation
A composite index is sorted by the first column, then by the second within it, like a phone book. It helps queries on a leading prefix of its columns; searching only by first_name usually can't use it well.