GATE DA 2024, Q.55: Which indexes speed up a range + equality query?
The question
Schema: Movie(ID, CustomerRating), Genre(ID, Name), Movie_Genre(MovieID, GenreID). The query selects rows where Movie.CustomerRating > 3.4 and Genre.Name = "Comedy", joined on the IDs. Which indexing options can speed it up?
- (A) B+ tree on all attributes
- (B) Hash index on Genre.Name, B+ tree on the remaining attributes
- (C) Hash index on Movie.CustomerRating, B+ tree on the remaining attributes
- (D) Hash index on all attributes
Solve it step by step
- Two kinds of index. A B+ tree keeps values sorted. A hash index scatters them across buckets.
- The range condition. CustomerRating > 3.4 is a range. In a B+ tree it is one run of leaves: find 3.6, then walk right.
- Range on a hash. In a hash index the matching ratings sit in every bucket, so a range cannot use it.
- The equality condition. Name = "Comedy" is equality, which a hash index finds in one step (a B+ tree works too).
- Decide. A and B help. C and D put a hash on the range column, so they do not.
Answer: A, B
Official IISc Bengaluru answer key: A; B.
Common mistake. Assuming a hash index is always faster. It only helps equality (=); ranges (>, <, BETWEEN) need sorted order.
Remember. Hash index: equality only. B+ tree: equality and ranges.
Want every question solved? The past-paper pack has all 195 questions from 2024, 2025 and 2026 for ₹499. The cheat sheet pack has 23 printable sheets for ₹399.
See the past-paper pack See the cheat sheetsSource: official GATE DA 2024 question paper and answer key (IISc Bengaluru). The question is lightly reworded; every number and option is kept.