Bird
0
0

Given a table products with a B-tree index on product_id, what will the query optimizer most likely do when running:

medium📝 query result Q13 of 15
SQL - Indexes and Query Performance
Given a table products with a B-tree index on product_id, what will the query optimizer most likely do when running:
SELECT * FROM products WHERE product_id = 123;?
AUse the B-tree index to quickly locate the row with product_id 123
BPerform a full table scan ignoring the index
CUse a hash index lookup instead of the B-tree
DScan only the first 10 rows of the table
Step-by-Step Solution
Solution:
  1. Step 1: Understand query condition and index

    The query searches for a specific product_id value, which matches the indexed column.
  2. Step 2: Predict optimizer behavior with B-tree index

    The optimizer uses the B-tree index to quickly find the matching row without scanning the whole table.
  3. Final Answer:

    Use the B-tree index to quickly locate the row with product_id 123 -> Option A
  4. Quick Check:

    Indexed search = fast lookup [OK]
Quick Trick: Queries on indexed columns use B-tree for fast lookup [OK]
Common Mistakes:
  • Assuming full table scan always happens
  • Confusing B-tree with hash index usage
  • Thinking partial scan happens without index

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes