Bird
0
0

Given the table products(id INT, name TEXT) with a hash index on id, what will the query SELECT * FROM products WHERE id = 10; most likely use?

medium📝 query result Q13 of 15
PostgreSQL - Indexing Strategies

Given the table products(id INT, name TEXT) with a hash index on id, what will the query SELECT * FROM products WHERE id = 10; most likely use?

AA sequential scan ignoring the index
BA hash index scan for fast equality lookup
CA bitmap index scan for range search
DA full table lock before scanning
Step-by-Step Solution
Solution:
  1. Step 1: Identify query condition type

    The query uses an equality condition on the id column: id = 10.
  2. Step 2: Match index type to query

    Since there is a hash index on id, PostgreSQL will use a hash index scan to quickly find rows where id equals 10.
  3. Final Answer:

    A hash index scan for fast equality lookup -> Option B
  4. Quick Check:

    Equality query + hash index = hash index scan [OK]
Quick Trick: Equality WHERE uses hash index scan if available. [OK]
Common Mistakes:
  • Assuming sequential scan always happens
  • Confusing bitmap index with hash index
  • Thinking hash index supports range queries

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes