Re: postgres_fdw: wrong results with self join + enable_nestloop off

Etsuro Fujita <etsuro.fujita@gmail.com>

From: Etsuro Fujita <etsuro.fujita@gmail.com>
To: Richard Guo <guofenglinux@gmail.com>
Cc: Nishant Sharma <nishant.sharma@enterprisedb.com>, Suraj Kharage <suraj.kharage@enterprisedb.com>, pgsql-hackers@postgresql.org
Date: 2023-06-08T10:30:52Z
Lists: pgsql-hackers
Hi Richard,

On Tue, Jun 6, 2023 at 12:20 PM Richard Guo <guofenglinux@gmail.com> wrote:
> On Mon, Jun 5, 2023 at 9:19 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:
>> To avoid this issue, I am wondering if we should modify
>> add_paths_to_joinrel() in back branches so that it just disallows the
>> FDW to consider pushing down joins when the restrictlist has
>> pseudoconstant clauses.  Attached is a patch for that.

> I think we can do that in back branches.  But I'm a little concerned
> that we'd miss a better plan if FDW cannot push down joins in such
> cases.  I may be worrying over nothing though if it's not common that
> the restrictlist has pseudoconstant clauses.

Yeah, it is unfortunate that we would not get better plans.  Given
that it took quite a long time to find this issue, I suppose that
users seldom do foreign joins with pseudoconstant clauses, though.

Anyway thanks for working on this, Richard!

Best regards,
Etsuro Fujita



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Re-allow FDWs and custom scan providers to replace joins with pseudoconstant quals.

  2. Disallow replacing joins with scans in problematic cases.

  3. doc: PQinitOpenSSL and PQinitSSL are obsolete in OpenSSL 1.1.0+