Re: Question about pull_up_sublinks_qual_recurse - Mailing list pgsql-hackers

From Andy Fan
Subject Re: Question about pull_up_sublinks_qual_recurse
Date
Msg-id CAKU4AWoJLhTaoeRX0_sMRy+8peCDxJR+mgm76Oy9nikqGnfyhw@mail.gmail.com
Whole thread Raw
In response to Question about pull_up_sublinks_qual_recurse  (Andy Fan <zhihui.fan1213@gmail.com>)
Responses Re: Question about pull_up_sublinks_qual_recurse  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
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

pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: New docs chapter on Transaction Management and related changes
Next
From: Alvaro Herrera
Date:
Subject: Re: Move backup-related code to xlogbackup.c/.h