From: Tomas Vondra Date: Sun, 22 Jan 2017 17:57:40 +0000 (+0100) Subject: add a redistribution missing in create_distinct_paths X-Git-Tag: XL_10_R1BETA1~410 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=7178df974a057d005c1977c6a714923d83bbf273;p=postgres-xl.git add a redistribution missing in create_distinct_paths A redistribution was missing in the loop handling paths already sorted for the DISTINCT case. So add it there. --- diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 2f1dc845b8..4ea83f0b0d 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -4929,6 +4929,16 @@ create_distinct_paths(PlannerInfo *root, if (pathkeys_contained_in(needed_pathkeys, path->pathkeys)) { + /* + * Make sure the distribution matches the distinct clause, + * needed by the UNIQUE path. + * + * FIXME This could probably benefit from pushing a UNIQUE + * to the remote side, and only doing a merge locally. + */ + if (!grouping_distribution_match(root, parse, path, parse->distinctClause)) + path = create_remotesubplan_path(root, path, NULL); + add_path(distinct_rel, (Path *) create_upper_unique_path(root, distinct_rel, path,