CS FundamentalsHardWipro · Cognizant technical pattern

Table Orders has a composite B-tree index on (city, amount). Which WHERE clause can use this index to narrow the search most effectively?

  1. A. WHERE amount > 500
  2. B. WHERE amount = 500 OR city = 'Delhi'
  3. C. WHERE UPPER(city) = 'DELHI'
  4. D. WHERE city = 'Delhi' AND amount > 500

Correct answer: D. WHERE city = 'Delhi' AND amount > 500

A composite index is sorted by city first, then amount, so it serves predicates on its leftmost prefix: an equality on city plus a range on amount is ideal. amount alone skips the leading column; the OR needs both columns independently; wrapping city in a function hides it from a plain index.

More DBMS and SQL questions

Exams that ask this topic