mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Re-allow FDWs and custom scan providers to replace joins with pseudoconstant quals.
This was disabled in commit 6f80a8d9c
due to the lack of support for
handling of pseudoconstant quals assigned to replaced joins in
createplan.c. To re-allow it, this patch adds the support by 1)
modifying the ForeignPath and CustomPath structs so that if they
represent foreign and custom scans replacing a join with a scan, they
store the list of RestrictInfo nodes to apply to the join, as in
JoinPaths, and by 2) modifying create_scan_plan() in createplan.c so
that it uses that list in that case, instead of the baserestrictinfo
list, to get pseudoconstant quals assigned to the join, as mentioned in
the commit message for that commit.
Important item for the release notes: this is non-backwards-compatible
since it modifies the ForeignPath and CustomPath structs, as mentioned
above, and changes the argument lists for FDW helper functions
create_foreignscan_path(), create_foreign_join_path(), and
create_foreign_upper_path().
Richard Guo, with some additional changes by me, reviewed by Nishant
Sharma, Suraj Kharage, and Richard Guo.
Discussion: https://postgr.es/m/CADrsxdbcN1vejBaf8a%2BQhrZY5PXL-04mCd4GDu6qm6FigDZd6Q%40mail.gmail.com
This commit is contained in:
@ -2316,31 +2316,21 @@ SELECT t1."C 1" FROM "S 1"."T 1" t1, LATERAL (SELECT DISTINCT t2.c1, t3.c1 FROM
|
||||
1
|
||||
(10 rows)
|
||||
|
||||
-- join with pseudoconstant quals, not pushed down.
|
||||
-- join with pseudoconstant quals
|
||||
EXPLAIN (VERBOSE, COSTS OFF)
|
||||
SELECT t1.c1, t2.c1 FROM ft1 t1 JOIN ft2 t2 ON (t1.c1 = t2.c1 AND CURRENT_USER = SESSION_USER) ORDER BY t1.c3, t1.c1 OFFSET 100 LIMIT 10;
|
||||
QUERY PLAN
|
||||
-------------------------------------------------------------------------------
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit
|
||||
Output: t1.c1, t2.c1, t1.c3
|
||||
-> Sort
|
||||
-> Result
|
||||
Output: t1.c1, t2.c1, t1.c3
|
||||
Sort Key: t1.c3, t1.c1
|
||||
-> Result
|
||||
Output: t1.c1, t2.c1, t1.c3
|
||||
One-Time Filter: (CURRENT_USER = SESSION_USER)
|
||||
-> Hash Join
|
||||
Output: t1.c1, t1.c3, t2.c1
|
||||
Hash Cond: (t2.c1 = t1.c1)
|
||||
-> Foreign Scan on public.ft2 t2
|
||||
Output: t2.c1
|
||||
Remote SQL: SELECT "C 1" FROM "S 1"."T 1"
|
||||
-> Hash
|
||||
Output: t1.c1, t1.c3
|
||||
-> Foreign Scan on public.ft1 t1
|
||||
Output: t1.c1, t1.c3
|
||||
Remote SQL: SELECT "C 1", c3 FROM "S 1"."T 1"
|
||||
(19 rows)
|
||||
One-Time Filter: (CURRENT_USER = SESSION_USER)
|
||||
-> Foreign Scan
|
||||
Output: t1.c1, t1.c3, t2.c1
|
||||
Relations: (public.ft1 t1) INNER JOIN (public.ft2 t2)
|
||||
Remote SQL: SELECT r1."C 1", r2."C 1", r1.c3 FROM ("S 1"."T 1" r1 INNER JOIN "S 1"."T 1" r2 ON (((r2."C 1" = r1."C 1")))) ORDER BY r1.c3 ASC NULLS LAST, r1."C 1" ASC NULLS LAST
|
||||
(9 rows)
|
||||
|
||||
-- non-Var items in targetlist of the nullable rel of a join preventing
|
||||
-- push-down in some cases
|
||||
|
Reference in New Issue
Block a user