From: Tomas Vondra Date: Sat, 28 Jan 2017 22:43:01 +0000 (+0100) Subject: redistribute Limit nodes nested in MinMaxAggPath X-Git-Tag: XL_10_R1BETA1~395 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=6f64f49eb8d64baf077f13ffc2e3fd3f49b730bb;p=postgres-xl.git redistribute Limit nodes nested in MinMaxAggPath Make sure min/max path are redistributed. Doing it in createplan.c is probably only a temporary solution, though. First, it breaks the costing model (the path cost does not include the redistribution), and it also probably breaks how distribution is propagated up the path tree. --- diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 5adde29bc6..182c81f06e 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -1914,6 +1914,35 @@ create_minmaxagg_plan(PlannerInfo *root, MinMaxAggPath *best_path) plan->plan_width = mminfo->path->pathtarget->width; plan->parallel_aware = false; + /* + * XL: Add a remote subplan, splitting the LIMIT into a remote and + * local part LIMIT parts. + * + * XXX This should probably happen when constructing the path in + * create_minmaxagg_path(), not this late. + * + * XXX The costing in here is mostly bogus. Not that it'd matter + * this late, though. + */ + if (mminfo->path->distribution) + { + plan = (Plan *) make_remotesubplan(root, plan, + NULL, + mminfo->path->distribution, + mminfo->path->pathkeys); + + plan = (Plan *) make_limit(plan, + subparse->limitOffset, + subparse->limitCount, + 0, 1); + + plan->startup_cost = mminfo->path->startup_cost; + plan->total_cost = mminfo->pathcost; + plan->plan_rows = 1; + plan->plan_width = mminfo->path->pathtarget->width; + plan->parallel_aware = false; + } + /* Convert the plan into an InitPlan in the outer query. */ SS_make_initplan_from_plan(root, subroot, plan, mminfo->param); }