CS FundamentalsModerateGATE CS · Amazon/Microsoft SDE MCQ

A query plan computes σ_{dept = 'D1' ∧ sal > 50}(Emp ⋈ Dept). Which rewrite is a heuristic optimizer most likely to apply first, and why?

  1. A. Replace the join with a Cartesian product, since products need no index
  2. B. Push the selections below the join so fewer tuples enter it
  3. C. Pull projections above the selection so every attribute stays available
  4. D. Split the conjunction into two separate joins on Emp and on Dept

Correct answer: B. Push the selections below the join so fewer tuples enter it

Selections are pushed as low as possible (here onto Emp, or onto whichever relation owns each attribute) to shrink the join input; this is usually the biggest win. Products are never cheaper than an equivalent join, and projections are pushed down, not up.

More DBMS and SQL questions

Exams that ask this topic