Difficulty: Easy
Correct Answer: Correct — regular subqueries are processed before the outer query
Explanation:
Introduction / Context:
Understanding evaluation order helps predict results and performance. In general, non-correlated subqueries are computed first and their result is then used by the outer query. Correlated subqueries may be re-evaluated per outer row.
Given Data / Assumptions:
Concept / Approach:
For non-correlated subqueries, the DBMS can compute the inner result set once and reuse it, or transform the query (e.g., to a join). Either way, the semantics match “bottom-up” processing.
Step-by-Step Solution:
Identify a non-correlated subquery in SELECT, WHERE, or FROM.Recognize that its result does not depend on outer rows.DBMS evaluates or rewrites it so the outer query can reference the produced set/value.Therefore, the statement that regular subqueries are processed bottom-up is correct semantically.
Verification / Alternative check:
EXPLAIN plans often show subquery computation (or transformation to derived tables/joins) before outer operations.
Why Other Options Are Wrong:
Claiming subqueries are evaluated last contradicts typical semantics. GROUP BY presence or client software does not dictate logical order.
Common Pitfalls:
Assuming the same for correlated subqueries; those may run per outer row unless decorrelated by the optimizer.
Final Answer:
Correct — regular (non-correlated) subqueries are effectively processed bottom-up.
Discussion & Comments