summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTomas Vondra2020-12-21 17:09:57 +0000
committerTomas Vondra2020-12-21 17:10:20 +0000
commitf4a3c0b06250ddc8ae09b59b87cf68e9bc0d7ca1 (patch)
treee4670149068b7cfe6abdedf560fb460239cd2c40 /src/test
parent29f8f546767ebb4253f6dc37815e2d95fff9acd0 (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/test')
-rw-r--r--src/test/regress/expected/incremental_sort.out13
-rw-r--r--src/test/regress/sql/incremental_sort.sql4
2 files changed, 17 insertions, 0 deletions
diff --git a/src/test/regress/expected/incremental_sort.out b/src/test/regress/expected/incremental_sort.out
index 7cf2eee7c14..51471ae92de 100644
--- a/src/test/regress/expected/incremental_sort.out
+++ b/src/test/regress/expected/incremental_sort.out
@@ -1468,6 +1468,19 @@ explain (costs off) select * from t union select * from t order by 1,3;
-> Parallel Seq Scan on t t_1
(13 rows)
+-- Full sort, not just incremental sort can be pushed below a gather merge path
+-- by generate_useful_gather_paths.
+explain (costs off) select distinct a,b from t;
+ QUERY PLAN
+------------------------------------------
+ Unique
+ -> Gather Merge
+ Workers Planned: 2
+ -> Sort
+ Sort Key: a, b
+ -> Parallel Seq Scan on t
+(6 rows)
+
drop table t;
-- Sort pushdown can't go below where expressions are part of the rel target.
-- In particular this is interesting for volatile expressions which have to
diff --git a/src/test/regress/sql/incremental_sort.sql b/src/test/regress/sql/incremental_sort.sql
index 3ee11c394b9..cb48f200ce5 100644
--- a/src/test/regress/sql/incremental_sort.sql
+++ b/src/test/regress/sql/incremental_sort.sql
@@ -220,6 +220,10 @@ explain (costs off) select a,b,sum(c) from t group by 1,2 order by 1,2,3 limit 1
set enable_hashagg to off;
explain (costs off) select * from t union select * from t order by 1,3;
+-- Full sort, not just incremental sort can be pushed below a gather merge path
+-- by generate_useful_gather_paths.
+explain (costs off) select distinct a,b from t;
+
drop table t;
-- Sort pushdown can't go below where expressions are part of the rel target.