> > Later we tried to pull up the EXISTS sublink to t1 OR t2 *separately*, > since > this subselect referenced to t1 *AND* t2, so we CAN'T pull up the > sublink. I > am thinking why we have to pull up it t1 OR t2 rather than JoinExpr(t1, > t2), > I think the latter one is better. >
After some more self review, I find my proposal has the following side effects. select * from t1 where exists (select 1 from t2 where exists (select 1 from t3 where t3.c = t1.c) and t2.a = t1.a); In the above example, the innermost sublink will be joined with SemiJoin (t1 t2) in the patched version, but joined with t1 in the current master. However, even if we set the JoinTree with SemiJoin(SemiJoin(t1 t2), t3), the join reorder functions can generate a path which joins t1 with t3 first and then t2 still. So any hint about this patch's self-review is welcome. -- Best Regards Andy Fan