You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Suppress unnecessary explicit sorting for EPQ mergejoin path
When building a ForeignPath for a joinrel, if there's a possibilitythat EvalPlanQual will be executed, we must identify a suitable pathfor EPQ checks. If the outer or inner path of the chosen path is aForeignPath representing a pushed-down join, we replace it with itsfdw_outerpath to ensure that the EPQ check path consists entirely oflocal joins.If the chosen path is a MergePath, and its outer or inner path is aForeignPath that is not already well enough ordered, the MergePathwill have non-NIL outersortkeys or innersortkeys indicating thedesired ordering to be created by an explicit Sort node. If we thenreplace the outer or inner path with its corresponding fdw_outerpath,and that path is already sufficiently ordered, we end up in aninconsistent state: the MergePath has non-NIL outersortkeys orinnersortkeys, and its input path is already properly ordered. Thisinconsistency can result in an Assert failure or the addition of aredundant Sort node.To fix, check if the new outer or inner path of a MergePath is alreadyproperly sorted, and set its outersortkeys or innersortkeys to NIL ifso.Bug: #18902Reported-by: Nikita Kalinin <n.kalinin@postgrespro.ru>Author: Richard Guo <guofenglinux@gmail.com>Reviewed-by: Tender Wang <tndrwang@gmail.com>Discussion:https://postgr.es/m/18902-71c1bed2b9f7c46f@postgresql.org
Remote SQL: SELECT r1."C 1", r1.c2, r1.c3, r1.c4, r1.c5, r1.c6, r1.c7, r1.c8, CASE WHEN (r1.*)::text IS NOT NULL THEN ROW(r1."C 1", r1.c2, r1.c3, r1.c4, r1.c5, r1.c6, r1.c7, r1.c8) END, r2.c1, r2.c2, r2.c3, CASE WHEN (r2.*)::text IS NOT NULL THEN ROW(r2.c1, r2.c2, r2.c3) END, r3.c1, r3.c2, r3.c3, CASE WHEN (r3.*)::text IS NOT NULL THEN ROW(r3.c1, r3.c2, r3.c3) END FROM (("S 1"."T 1" r1 INNER JOIN "S 1"."T 3" r2 ON (((r1."C 1" = r2.c1)) AND ((r1."C 1" < 100)))) INNER JOIN "S 1"."T 4" r3 ON (((r1."C 1" = r3.c1)) AND ((r3.c1 < 100)))) FOR UPDATE OF r1 FOR UPDATE OF r2 FOR UPDATE OF r3