Bird
0
0

Why might a database optimizer choose to rewrite a subquery as a JOIN internally?

hard📝 Conceptual Q10 of 15
SQL - Subqueries
Why might a database optimizer choose to rewrite a subquery as a JOIN internally?
ABecause JOINs can be optimized with indexes and reduce repeated scanning.
BBecause subqueries are always slower and not supported in modern SQL.
CBecause JOINs use less memory than subqueries in all cases.
DBecause subqueries cannot filter rows effectively.
Step-by-Step Solution
Solution:
  1. Step 1: Understand optimizer behavior

    Database optimizers rewrite queries to improve performance by using the best execution plan.
  2. Step 2: Reason why JOIN rewrite helps

    JOINs can use indexes and avoid scanning subqueries repeatedly, improving speed.
  3. Final Answer:

    Because JOINs can be optimized with indexes and reduce repeated scanning. -> Option A
  4. Quick Check:

    Optimizer rewrites = better JOIN plans [OK]
Quick Trick: Optimizers rewrite subqueries to JOINs for speed [OK]
Common Mistakes:
MISTAKES
  • Thinking subqueries are unsupported
  • Assuming JOINs always use less memory
  • Believing subqueries cannot filter rows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes