]> granicus.if.org Git - postgresql/commitdiff
Re-fix wrong costing of Sort under Gather Merge.
authorRobert Haas <rhaas@postgresql.org>
Tue, 19 Dec 2017 15:34:35 +0000 (10:34 -0500)
committerRobert Haas <rhaas@postgresql.org>
Tue, 19 Dec 2017 15:42:17 +0000 (10:42 -0500)
Commit dc02c7bca4dccf7de278cdc6b3325a829e75b252 changed this call
to create_sort_path() to take -1 rather than limit_tuples because,
at that time, there was no way for a Sort beneath a Gather Merge
to become a top-N sort.

Later, commit 3452dc5240da43e833118484e1e9b4894d04431c provided
a way for a Sort beneath a Gather Merge to become a top-N sort,
but failed to revert the previous commit in the process.  Do that.

Report and analysis by Jeff Janes; patch by Thomas Munro; review by
Amit Kapila and by me.

Discussion: http://postgr.es/m/CAEepm=1BWtC34vUroA0Uqjw02MaqdUrW+d6WD85_k8SLyPiKHQ@mail.gmail.com

src/backend/optimizer/plan/planner.c

index e8bc15c35d20b0a7194e2c03c1317323281cbdcd..382791fadb42a688e61e3109a2e12272357187d0 100644 (file)
@@ -5059,7 +5059,7 @@ create_ordered_paths(PlannerInfo *root,
                                                                                         ordered_rel,
                                                                                         cheapest_partial_path,
                                                                                         root->sort_pathkeys,
-                                                                                        -1.0);
+                                                                                        limit_tuples);
 
                        total_groups = cheapest_partial_path->rows *
                                cheapest_partial_path->parallel_workers;