From dc02c7bca4dccf7de278cdc6b3325a829e75b252 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Wed, 22 Mar 2017 14:42:03 -0400 Subject: [PATCH] Fix wrong costing of Sort under Gather Merge. There's no mechanism for such a sort to become a top-N sort, so we should pass -1 rather than limit_tuples to cost_sort(). Rushabh Lathia, per a report from Mithun Cy Discussion: http://postgr.es/m/CAGPqQf1akRcSgC9=6iwx=sEPap9UvPpHJLzg8_N+OuHdb6fL+g@mail.gmail.com --- src/backend/optimizer/plan/planner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index cbdea1f537..68d74cb432 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -4416,7 +4416,7 @@ create_ordered_paths(PlannerInfo *root, ordered_rel, cheapest_partial_path, root->sort_pathkeys, - limit_tuples); + -1.0); total_groups = cheapest_partial_path->rows * cheapest_partial_path->parallel_workers; -- 2.40.0