Bird
0
0

You have a query using columns customer_id and order_date. The index is created only on customer_id. Why might this cause a performance issue?

medium📝 Debug Q6 of 15
SQL - Indexes and Query Performance
You have a query using columns customer_id and order_date. The index is created only on customer_id. Why might this cause a performance issue?
ABecause indexes slow down all queries
BBecause customer_id is not a valid column
CBecause the index does not cover all columns used, causing table lookups
DBecause order_date cannot be indexed
Step-by-Step Solution
Solution:
  1. Step 1: Identify columns in the index

    The index covers only customer_id, not order_date.
  2. Step 2: Understand query needs

    The query uses both columns, so the index alone cannot satisfy it fully, causing extra table lookups.
  3. Final Answer:

    Because the index does not cover all columns used, causing table lookups -> Option C
  4. Quick Check:

    Partial index coverage = extra table access [OK]
Quick Trick: Index must cover all query columns to avoid table reads [OK]
Common Mistakes:
  • Assuming any index speeds all queries
  • Thinking columns cannot be indexed
  • Ignoring table lookups caused by partial indexes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes