Bird
0
0

Given a table orders with 1 million rows and an index on customer_id, what is the expected effect of running SELECT * FROM orders WHERE customer_id = 123;?

medium📝 query result Q13 of 15
SQL - Indexes and Query Performance
Given a table orders with 1 million rows and an index on customer_id, what is the expected effect of running SELECT * FROM orders WHERE customer_id = 123;?
AThe query will use the index to quickly find matching rows.
BThe query will scan all rows, ignoring the index.
CThe query will be slower because indexes slow down SELECT queries.
DThe query will fail because indexes cannot be used in WHERE clauses.
Step-by-Step Solution
Solution:
  1. Step 1: Understand index usage in WHERE clause

    Indexes help the database quickly locate rows matching the WHERE condition on indexed columns.
  2. Step 2: Apply to the query

    Since customer_id is indexed, the query uses the index to find rows without scanning all 1 million rows.
  3. Final Answer:

    The query will use the index to quickly find matching rows. -> Option A
  4. Quick Check:

    Indexed WHERE columns speed up SELECT [OK]
Quick Trick: WHERE on indexed columns uses index for fast lookup [OK]
Common Mistakes:
  • Thinking indexes slow down SELECT
  • Believing indexes are ignored in WHERE
  • Assuming query fails with indexes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes