CS FundamentalsHardGATE CS · DBMS

A query runs WHERE a = 7 AND b > 100 ORDER BY b. Which single B+ tree index serves it best?

  1. A. An index on b alone
  2. B. A hash index on (a, b)
  3. C. A composite index on (a, b)
  4. D. A composite index on (b, a)

Correct answer: C. A composite index on (a, b)

With (a, b), all entries with a = 7 are contiguous and already sorted by b, so the range b > 100 is one leaf scan in order. With (b, a), entries for a = 7 are scattered over the b range; a hash index cannot do ranges.

More DBMS and SQL questions

Exams that ask this topic