CS FundamentalsModerateGATE CS · Amazon/Microsoft SDE MCQ

Table T(a, b, c) has a composite B+ tree index on (a, b), and the query is SELECT b FROM T WHERE a = 5. What is the main benefit of this index here?

  1. A. It can answer the query with an index-only scan, never touching the table
  2. B. It is unusable, because the query does not filter on b
  3. C. It helps only if the table is clustered on (a, b)
  4. D. It can be used only with a full scan of all leaves

Correct answer: A. It can answer the query with an index-only scan, never touching the table

The predicate uses the leading column a, and the only output column b is also in the index, so the index covers the query and the base table need not be read. A filter on the leading column alone is enough to use a composite index.

More DBMS and SQL questions

Exams that ask this topic