Re: Pulling up direct-correlated ANY_SUBLINK

2022-10-30 Thread Andy Fan
0:00 2001 From: Andy Fan Date: Sun, 9 Oct 2022 17:47:23 +0800 Subject: [PATCH v1] 2 methods for Pulling up direct-correlated ANY_SUBLINK --- .../postgres_fdw/expected/postgres_fdw.out| 24 +- src/backend/optimizer/plan/subselect.c| 7 +- src/backend/optimizer/prep/prepjointr

Re: Pulling up direct-correlated ANY_SUBLINK

2022-07-21 Thread Richard Guo
On Tue, Sep 10, 2019 at 9:49 PM Tom Lane wrote: > > Can we try to pull up direct-correlated ANY SubLink with the help of > > LATERAL? > > Perhaps. But what's the argument that you'd end up with a better > plan? LATERAL pretty much constrains things to use a nestloop, > so I'm not sure there's a

Re: Pulling up direct-correlated ANY_SUBLINK

2020-08-18 Thread Andy Fan
On Tue, Sep 17, 2019 at 4:41 PM Richard Guo wrote: > > On Thu, Sep 12, 2019 at 11:35 PM Antonin Houska wrote: > >> Richard Guo wrote: >> >> > On Wed, Sep 11, 2019 at 3:25 PM Antonin Houska >> > wrote: >> > >> > >> > Nevertheless, I don't know how to overcome the problems that I >> > me

Re: Pulling up direct-correlated ANY_SUBLINK

2019-09-17 Thread Richard Guo
On Thu, Sep 12, 2019 at 11:35 PM Antonin Houska wrote: > Richard Guo wrote: > > > On Wed, Sep 11, 2019 at 3:25 PM Antonin Houska > > wrote: > > > > > > Nevertheless, I don't know how to overcome the problems that I > > mentioned > > upthread. > > > > > > Do you mean the problem "the

Re: Pulling up direct-correlated ANY_SUBLINK

2019-09-12 Thread Antonin Houska
Richard Guo wrote: > On Wed, Sep 11, 2019 at 3:25 PM Antonin Houska > wrote: > > > Nevertheless, I don't know how to overcome the problems that I > mentioned > upthread. > > > Do you mean the problem "the WHERE clause of the subquery didn't > participate in the SEMI JOIN evalu

Re: Pulling up direct-correlated ANY_SUBLINK

2019-09-11 Thread Richard Guo
Hi Tom, On Tue, Sep 10, 2019 at 9:48 PM Tom Lane wrote: > > > Can we try to pull up direct-correlated ANY SubLink with the help of > > LATERAL? > > Perhaps. But what's the argument that you'd end up with a better > plan? LATERAL pretty much constrains things to use a nestloop, > so I'm not sur

Re: Pulling up direct-correlated ANY_SUBLINK

2019-09-11 Thread Richard Guo
Hi Antonin, On Wed, Sep 11, 2019 at 3:25 PM Antonin Houska wrote: > > Nevertheless, I don't know how to overcome the problems that I mentioned > upthread. > Do you mean the problem "the WHERE clause of the subquery didn't participate in the SEMI JOIN evaluation"? Good news is it has been fixed

Re: Pulling up direct-correlated ANY_SUBLINK

2019-09-11 Thread Antonin Houska
Tom Lane wrote: > > Can we try to pull up direct-correlated ANY SubLink with the help of > > LATERAL? > > Perhaps. But what's the argument that you'd end up with a better > plan? LATERAL pretty much constrains things to use a nestloop, > so I'm not sure there's anything fundamentally different

Re: Pulling up direct-correlated ANY_SUBLINK

2019-09-11 Thread Richard Guo
Hi Antonin, On Tue, Sep 10, 2019 at 4:31 PM Antonin Houska wrote: > Richard Guo wrote: > > > Can we try to pull up direct-correlated ANY SubLink with the help of > > LATERAL? > > > By this way, we can convert the query: > > > > select * from a where a.i = ANY(select i from b where a.j > b.j); >

Re: Pulling up direct-correlated ANY_SUBLINK

2019-09-10 Thread Tom Lane
Richard Guo writes: > Currently we do not try to pull up sub-select of type ANY_SUBLINK if it > refers to any Vars of the parent query, as indicated in the code snippet > below: > if (contain_vars_of_level((Node *) subselect, 1)) > return NULL; > Why do we have this check? Because the

Re: Pulling up direct-correlated ANY_SUBLINK

2019-09-10 Thread Antonin Houska
Richard Guo wrote: > Can we try to pull up direct-correlated ANY SubLink with the help of > LATERAL? > By this way, we can convert the query: > > select * from a where a.i = ANY(select i from b where a.j > b.j); > > To: > > select * from a SEMI JOIN lateral(select * from b where a.j > b.j) >

Pulling up direct-correlated ANY_SUBLINK

2019-09-10 Thread Richard Guo
Hi, Currently we do not try to pull up sub-select of type ANY_SUBLINK if it refers to any Vars of the parent query, as indicated in the code snippet below: JoinExpr * convert_ANY_sublink_to_join(PlannerInfo *root, SubLink *sublink, Relids available_rels) { ...