Gradient LabSign up free

Home / GATE DA / 2024 / Q.55

GATE DA 2024, Q.55: Which indexes speed up a range + equality query?

DatabasesHash vs B+ tree indexes2 marksMSQ (more than one correct)Free

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?

Solve it step by step

  1. Two kinds of index. A B+ tree keeps values sorted. A hash index scatters them across buckets.
  2. 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.
  3. Range on a hash. In a hash index the matching ratings sit in every bucket, so a range cannot use it.
  4. The equality condition. Name = "Comedy" is equality, which a hash index finds in one step (a B+ tree works too).
  5. 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 sheets

Source: official GATE DA 2024 question paper and answer key (IISc Bengaluru). The question is lightly reworded; every number and option is kept.