Bird
0
0

Given a table orders with 1 million rows and an index on customer_id, what is the expected result of this query?

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 result of this query?
SELECT * FROM orders WHERE customer_id = 123;
AThe query will use the index to quickly find matching rows.
BThe query will return no rows because indexes hide data.
CThe query will fail because indexes cannot be used in WHERE clauses.
DThe query will scan all 1 million rows, taking a long time.
Step-by-Step Solution
Solution:
  1. Step 1: Understand index usage in WHERE clause

    An index on customer_id helps the database quickly locate rows matching that value.
  2. Step 2: Predict query behavior

    The database uses the index to avoid scanning all rows, speeding up the query.
  3. Final Answer:

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

    Index speeds WHERE search = D [OK]
Quick Trick: Indexes speed up WHERE filters on indexed columns [OK]
Common Mistakes:
  • Thinking indexes cause full table scans
  • Believing indexes prevent queries from running
  • Assuming indexes hide data from results

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes