Bird
0
0

When might a subquery perform better than a JOIN?

easy📝 Conceptual Q2 of 15
SQL - Subqueries
When might a subquery perform better than a JOIN?
AWhen joining large tables without indexes.
BWhen the database engine does not support JOINs.
CWhen the subquery returns a small, filtered set used in a WHERE clause.
DWhen the subquery is uncorrelated and returns many rows.
Step-by-Step Solution
Solution:
  1. Step 1: Identify subquery advantages

    Subqueries that return a small filtered set can reduce the data processed in the main query.
  2. Step 2: Compare with JOIN scenarios

    JOINs on large tables without indexes can be slower, but subqueries returning many rows usually perform worse.
  3. Final Answer:

    When the subquery returns a small, filtered set used in a WHERE clause. -> Option C
  4. Quick Check:

    Better subquery use = small filtered set [OK]
Quick Trick: Small filtered subqueries can outperform JOINs [OK]
Common Mistakes:
MISTAKES
  • Assuming subqueries always perform worse
  • Ignoring the size of the subquery result
  • Confusing correlated and uncorrelated subqueries

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes