Why Bother with Query Unnesting?
has been shown to be effective in other domains (e.g. logic);
eliminates intermediate data structures;
improves performance in many cases;
allows operator mix-up between inner and outer queries;
simplifies physical algorithms (no need for complex predicates).
Reminiscent to loop fusion and deforestation in programming
Notes:
Query unnesting is very important: canonical forms have been shown to be useful in other domains (i.e. disjunctive normal forms in logic). Normalization eliminates intermediate data structures created when two operations are composed. It often improves performance as well. The reason is that query unnesting promotes the operators of the inner query to the same level as the operators of the outer query, thus allowing operator mix-up. Query unnesting also makes physical algorithms simpler because their predicates do not contain complex computations, such as other queries.