Re: Add semi-join pushdown to postgres_fdw

Alexander Korotkov <aekorotkov@gmail.com>

From: Alexander Korotkov <aekorotkov@gmail.com>
To: Alexander Pyhalov <a.pyhalov@postgrespro.ru>
Cc: Robins Tharakan <tharakan@gmail.com>, Tomas Vondra <tomas.vondra@enterprisedb.com>, "Fujii.Yuki@df.MitsubishiElectric.co.jp" <Fujii.Yuki@df.mitsubishielectric.co.jp>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, Pgsql Hackers <pgsql-hackers@postgresql.org>, Ian Lawrence Barwick <barwick@gmail.com>, tndrwang@gmail.com
Date: 2025-03-18T11:19:36Z
Lists: pgsql-hackers
Hi, Alexander!

On Tue, Mar 18, 2025 at 1:13 PM Alexander Pyhalov
<a.pyhalov@postgrespro.ru> wrote:
> Alexander Korotkov писал(а) 2025-03-18 03:27:
> > Hi, Robins!
> >
> > On Tue, Mar 18, 2025 at 2:20 AM Robins Tharakan <tharakan@gmail.com>
> > wrote:
> >> On Mon, 4 Dec 2023 at 07:22, Alexander Korotkov <aekorotkov@gmail.com>
> >> wrote:
> >> >
> >> >
> >> > Now, I think this looks good.  I'm going to push this if no objections.
> >>
> >> After this commit, I began seeing an unexpected ERROR - see this
> >> bug-report.
> >> https://www.postgresql.org/message-id/18852-fb75b88160678f78%40postgresql.org
> >
> > Thank you for pointing.
> > I'll check this in the next couple of days.
> >
>
> It seems conditions, coming from semi-joins, are handled incorrectly
> under left and right join. When deparsing left/right joins and there are
> semi-joins in inner or outer part of the query, the corresponding part
> is deparsed as subquery. And we can't refer subquery vars from above, so
> just should not pull up the restrictinfos. The attached patch does
> exactly this.

Thank you for the fix.  It looks like this fix generally affects
left/right joins, not just semi-joins.  Can you confirm this doesn't
cause regression for other cases?

------
Regards,
Alexander Korotkov
Supabase



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. postgres_fdw: Avoid pulling up restrict infos from subqueries

  2. Add support for deparsing semi-joins to contrib/postgres_fdw

  3. Move PartitioPruneInfo out of plan nodes into PlannedStmt