diff options
author | Tomas Vondra <tomas.vondra@postgresql.org> | 2020-12-21 18:09:57 +0100 |
---|---|---|
committer | Tomas Vondra <tomas.vondra@postgresql.org> | 2020-12-21 18:10:20 +0100 |
commit | f4a3c0b06250ddc8ae09b59b87cf68e9bc0d7ca1 (patch) | |
tree | e4670149068b7cfe6abdedf560fb460239cd2c40 /src/backend/optimizer/path/allpaths.c | |
parent | 29f8f546767ebb4253f6dc37815e2d95fff9acd0 (diff) |
Consider unsorted paths in generate_useful_gather_paths
generate_useful_gather_paths used to skip unsorted paths (without any
pathkeys), but that is unnecessary - the later code actually can handle
such paths just fine by adding a Sort node. This is clearly a thinko,
preventing construction of useful plans.
Backpatch to 13, where Incremental Sort was introduced.
Author: James Coleman
Reviewed-by: Tomas Vondra
Backpatch-through: 13
Discussion: https://postgr.es/m/CAAaqYe8cK3g5CfLC4w7bs=hC0mSksZC=H5M8LSchj5e5OxpTAg@mail.gmail.com
Diffstat (limited to 'src/backend/optimizer/path/allpaths.c')
-rw-r--r-- | src/backend/optimizer/path/allpaths.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index 84a69b064a9..a1b3e4b8215 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -2900,7 +2900,8 @@ generate_useful_gather_paths(PlannerInfo *root, RelOptInfo *rel, bool override_r cheapest_partial_path = linitial(rel->partial_pathlist); /* - * Consider incremental sort paths for each interesting ordering. + * Consider sorted paths for each interesting ordering. We generate both + * incremental and full sort. */ foreach(lc, useful_pathkeys_list) { @@ -2914,14 +2915,6 @@ generate_useful_gather_paths(PlannerInfo *root, RelOptInfo *rel, bool override_r Path *subpath = (Path *) lfirst(lc2); GatherMergePath *path; - /* - * If the path has no ordering at all, then we can't use either - * incremental sort or rely on implicit sorting with a gather - * merge. - */ - if (subpath->pathkeys == NIL) - continue; - is_sorted = pathkeys_count_contained_in(useful_pathkeys, subpath->pathkeys, &presorted_keys); |