From 154a9069df268b2edd81a3f1f5ed6a879ef9c23c Mon Sep 17 00:00:00 2001 From: Tomas Vondra Date: Fri, 21 Apr 2017 22:56:14 +0200 Subject: [PATCH] Resolve regression failures in matview test suite All the failures are changes in query plans, switching from 2-phase Hash Aggregate to 1-phase Group Aggregate. This seems to be happening for two main reasons: (1) Due to the upper planner pathification we now build additional paths and cost them correctly. I've reviewed the plans and the Group Aggregate paths seem cheaper than Hash Aggregate. (2) The amount of data in the suite is rather small, so the 2-phase aggregation seems not worth it. --- src/test/regress/expected/matview.out | 38 +++++++++++++-------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/test/regress/expected/matview.out b/src/test/regress/expected/matview.out index c1c1739c96..a416540983 100644 --- a/src/test/regress/expected/matview.out +++ b/src/test/regress/expected/matview.out @@ -21,12 +21,12 @@ EXPLAIN (costs off) CREATE MATERIALIZED VIEW mvtest_tm AS SELECT type, sum(amt) AS totamt FROM mvtest_t GROUP BY type WITH NO DATA; QUERY PLAN ----------------------------------------------------------- - HashAggregate + GroupAggregate Group Key: type -> Remote Subquery Scan on all (datanode_1,datanode_2) - -> HashAggregate - Group Key: type - -> Seq Scan on t + -> Sort + Sort Key: type + -> Seq Scan on mvtest_t (6 rows) CREATE MATERIALIZED VIEW mvtest_tm AS SELECT type, sum(amt) AS totamt FROM mvtest_t GROUP BY type WITH NO DATA; @@ -58,17 +58,15 @@ SELECT * FROM mvtest_tm ORDER BY 1; -- create various views EXPLAIN (costs off) CREATE MATERIALIZED VIEW mvtest_tvm AS SELECT * FROM mvtest_tv ORDER BY type; - QUERY PLAN ------------------------------------------------------------------ - Sort - Sort Key: mvtest_t.type - -> HashAggregate - Group Key: t.type - -> Remote Subquery Scan on all (datanode_1,datanode_2) - -> HashAggregate - Group Key: t.type - -> Seq Scan on t -(8 rows) + QUERY PLAN +----------------------------------------------------------- + GroupAggregate + Group Key: mvtest_t.type + -> Remote Subquery Scan on all (datanode_1,datanode_2) + -> Sort + Sort Key: mvtest_t.type + -> Seq Scan on mvtest_t +(6 rows) CREATE MATERIALIZED VIEW mvtest_tvm AS SELECT * FROM mvtest_tv ORDER BY type; SELECT * FROM mvtest_tvm; @@ -89,12 +87,12 @@ EXPLAIN (costs off) QUERY PLAN ----------------------------------------------------------------- Aggregate - -> HashAggregate - Group Key: t.type + -> GroupAggregate + Group Key: mvtest_t.type -> Remote Subquery Scan on all (datanode_1,datanode_2) - -> HashAggregate - Group Key: t.type - -> Seq Scan on t + -> Sort + Sort Key: mvtest_t.type + -> Seq Scan on mvtest_t (7 rows) CREATE MATERIALIZED VIEW mvtest_tvvm AS SELECT * FROM mvtest_tvv; -- 2.39.5