Bird
0
0

Which statement best describes how PostgreSQL executes a correlated subquery?

easy📝 Conceptual Q2 of 15
PostgreSQL - Subqueries in PostgreSQL
Which statement best describes how PostgreSQL executes a correlated subquery?
AIt executes the subquery once and reuses the result for all outer rows.
BIt executes the subquery for each row of the outer query using that row's values.
CIt executes the subquery only if the outer query has no rows.
DIt executes the subquery after the outer query completes.
Step-by-Step Solution
Solution:
  1. Step 1: Identify execution timing of correlated subqueries

    Correlated subqueries run once per outer query row, using that row's values.
  2. Step 2: Eliminate incorrect options

    Options B, C, and D describe behaviors not matching correlated subqueries.
  3. Final Answer:

    It executes the subquery for each row of the outer query using that row's values. -> Option B
  4. Quick Check:

    Execution per outer row = It executes the subquery for each row of the outer query using that row's values. [OK]
Quick Trick: Correlated subqueries run repeatedly, once per outer row. [OK]
Common Mistakes:
  • Assuming subquery runs only once.
  • Thinking subquery runs after outer query.
  • Confusing execution order.

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes