Re: postgres_fdw: wrong results with self join + enable_nestloop off
Nishant Sharma <nishant.sharma@enterprisedb.com>
From: Nishant Sharma <nishant.sharma@enterprisedb.com>
To: Etsuro Fujita <etsuro.fujita@gmail.com>
Cc: pgsql-hackers@postgresql.org
Date: 2023-04-17T05:30:05Z
Lists: pgsql-hackers
Thanks Etsuro for your response! One small typo correction in my answer to "What is the technical issue?" "it is *not* considered a pseudo constant" --> "it is considered a pseudo constant" Regards, Nishant. On Fri, Apr 14, 2023 at 6:21 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote: > Hi Nishant, > > On Fri, Apr 14, 2023 at 8:39 PM Nishant Sharma > <nishant.sharma@enterprisedb.com> wrote: > > I debugged this issue and was able to find a fix for the same. Kindly > please refer to the attached fix. With the fix I am able to resolve the > issue. > > Thanks for the report and patch! > > > What is the technical issue? > > The problem here is the use of extract_actual_clauses. Because of which > the plan creation misses adding the second condition of AND i.e "now() < > '23-Feb-2020'::timestamp" in the plan. Because it is not considered a > pseudo constant and extract_actual_clause is passed with false as the > second parameter and it gets skipped from the list. As a result that > condition is never taken into consideration as either one-time filter > (before or after) or part of SQL remote execution > > > > Why do I think the fix is correct? > > The fix is simple, where we have created a new function similar to > extract_actual_clause which just extracts all the conditions from the list > with no checks and returns the list to the caller. As a result all > conditions would be taken into consideration in the query plan. > > I think that the root cause for this issue would be in the > create_scan_plan handling of pseudoconstant quals when creating a > foreign-join (or custom-join) plan. Anyway, I will look at your patch > closely, first. > > 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 →
-
Re-allow FDWs and custom scan providers to replace joins with pseudoconstant quals.
- 9e9931d2bf40 17.0 landed
-
Disallow replacing joins with scans in problematic cases.
- db01f26968f2 11.21 landed
- 9edf72aa7644 12.16 landed
- 730f983effa5 13.12 landed
- b0e390e6d1d6 14.9 landed
- d1ef5631e620 15.4 landed
- 695f5deb7902 16.0 landed
- 6f80a8d9c137 17.0 landed
-
doc: PQinitOpenSSL and PQinitSSL are obsolete in OpenSSL 1.1.0+
- 928e05ddfd40 16.0 cited