CS FundamentalsModerateGATE CS · Product placement

A query optimizer rewrites σ_{city='Pune'}(Customer ⋈ Orders) as σ_{city='Pune'}(Customer) ⋈ Orders, where city is an attribute of Customer only. Why is this rewrite valid and usually beneficial?

  1. A. Selection commutes with join when it uses only one input's attributes, and filtering early shrinks the join input
  2. B. It is valid only for outer joins
  3. C. It changes the result but is faster
  4. D. It is valid only if city is a key

Correct answer: A. Selection commutes with join when it uses only one input's attributes, and filtering early shrinks the join input

Pushing a selection below a join is an equivalence whenever the predicate mentions attributes of one operand only; it reduces the number of tuples the join must process.

More DBMS and SQL questions

Exams that ask this topic