Bird
0
0

Consider a table logs with 10 million rows and an index on event_date. What will happen if you run this query?

medium📝 query result Q5 of 15
SQL - Indexes and Query Performance
Consider a table logs with 10 million rows and an index on event_date. What will happen if you run this query?
SELECT * FROM logs WHERE event_date > '2024-01-01';
AThe index will be used to quickly find matching rows
BThe query will perform a full table scan ignoring the index
CThe query will return an error due to date format
DThe index will be rebuilt during the query
Step-by-Step Solution
Solution:
  1. Step 1: Analyze index usage for range queries

    Indexes on date columns support range queries like greater than, so the index will be used to find rows after 2024-01-01 efficiently.
  2. Step 2: Verify query correctness

    The date format is standard and the query is valid; no errors or index rebuilds occur during SELECT.
  3. Final Answer:

    The index will be used to quickly find matching rows -> Option A
  4. Quick Check:

    Range queries use indexes efficiently = C [OK]
Quick Trick: Range filters on indexed columns use indexes for speed [OK]
Common Mistakes:
  • Assuming indexes only help equality filters
  • Thinking date format causes errors
  • Believing indexes rebuild on SELECT

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes