From 256e7d1540533ecfe8079e0f9f293c55ad9b800c Mon Sep 17 00:00:00 2001 From: Sait Talha Nisanci Date: Thu, 19 Aug 2021 13:11:02 +0300 Subject: [PATCH] Add alternative output for window_functions --- .../expected/insert_select_repartition.out | 1 - .../regress/expected/window_functions.out | 52 ++++++++++++------- .../regress/expected/window_functions_0.out | 20 ++++--- 3 files changed, 46 insertions(+), 27 deletions(-) diff --git a/src/test/regress/expected/insert_select_repartition.out b/src/test/regress/expected/insert_select_repartition.out index 163985ace..afa54b7e8 100644 --- a/src/test/regress/expected/insert_select_repartition.out +++ b/src/test/regress/expected/insert_select_repartition.out @@ -1209,7 +1209,6 @@ ON CONFLICT(c1, c2, c3, c4, c5, c6) DO UPDATE SET cardinality = enriched.cardinality + excluded.cardinality, sum = enriched.sum + excluded.sum; -DEBUG: rehashing catalog cache id 14 for pg_opclass; 17 tups, 8 buckets at character 224 DEBUG: INSERT target table and the source relation of the SELECT partition column value must be colocated in distributed INSERT ... SELECT DEBUG: Router planner cannot handle multi-shard select queries DEBUG: performing repartitioned INSERT ... SELECT diff --git a/src/test/regress/expected/window_functions.out b/src/test/regress/expected/window_functions.out index 0a41bc0cc..6657c3670 100644 --- a/src/test/regress/expected/window_functions.out +++ b/src/test/regress/expected/window_functions.out @@ -1386,12 +1386,16 @@ LIMIT 5; Sort Key: users_table.user_id, (avg(users_table.value_1)) DESC Presorted Key: users_table.user_id -> WindowAgg - -> Sort + -> Incremental Sort Sort Key: users_table.user_id, (('1'::numeric / ('1'::numeric + avg(users_table.value_1)))) - -> HashAggregate + Presorted Key: users_table.user_id + -> GroupAggregate Group Key: users_table.user_id, users_table.value_2 - -> Seq Scan on users_table_1400256 users_table -(18 rows) + -> Incremental Sort + Sort Key: users_table.user_id, users_table.value_2 + Presorted Key: users_table.user_id + -> Index Scan using is_index1_1400256 on users_table_1400256 users_table +(22 rows) EXPLAIN (COSTS FALSE) SELECT @@ -1418,12 +1422,16 @@ LIMIT 5; Sort Key: users_table.user_id, (avg(users_table.value_1)) DESC Presorted Key: users_table.user_id -> WindowAgg - -> Sort + -> Incremental Sort Sort Key: users_table.user_id, (('1'::numeric / ('1'::numeric + avg(users_table.value_1)))) - -> HashAggregate + Presorted Key: users_table.user_id + -> GroupAggregate Group Key: users_table.user_id, users_table.value_2 - -> Seq Scan on users_table_1400256 users_table -(18 rows) + -> Incremental Sort + Sort Key: users_table.user_id, users_table.value_2 + Presorted Key: users_table.user_id + -> Index Scan using is_index1_1400256 on users_table_1400256 users_table +(22 rows) EXPLAIN (COSTS FALSE) SELECT @@ -1435,7 +1443,7 @@ FROM GROUP BY user_id, value_2 ORDER BY user_id, avg(value_1) DESC LIMIT 5; - QUERY PLAN + QUERY PLAN --------------------------------------------------------------------- Limit -> Sort @@ -1450,12 +1458,16 @@ LIMIT 5; Sort Key: users_table.user_id, (avg(users_table.value_1)) DESC Presorted Key: users_table.user_id -> WindowAgg - -> Sort + -> Incremental Sort Sort Key: users_table.user_id, ((1 / (1 + sum(users_table.value_2)))) - -> HashAggregate + Presorted Key: users_table.user_id + -> GroupAggregate Group Key: users_table.user_id, users_table.value_2 - -> Seq Scan on users_table_1400256 users_table -(18 rows) + -> Incremental Sort + Sort Key: users_table.user_id, users_table.value_2 + Presorted Key: users_table.user_id + -> Index Scan using is_index1_1400256 on users_table_1400256 users_table +(22 rows) EXPLAIN (COSTS FALSE) SELECT @@ -1467,7 +1479,7 @@ FROM GROUP BY user_id, value_2 ORDER BY user_id, avg(value_1) DESC LIMIT 5; - QUERY PLAN + QUERY PLAN --------------------------------------------------------------------- Limit -> Sort @@ -1482,12 +1494,16 @@ LIMIT 5; Sort Key: users_table.user_id, (avg(users_table.value_1)) DESC Presorted Key: users_table.user_id -> WindowAgg - -> Sort + -> Incremental Sort Sort Key: users_table.user_id, (sum(users_table.value_2)) - -> HashAggregate + Presorted Key: users_table.user_id + -> GroupAggregate Group Key: users_table.user_id, users_table.value_2 - -> Seq Scan on users_table_1400256 users_table -(18 rows) + -> Incremental Sort + Sort Key: users_table.user_id, users_table.value_2 + Presorted Key: users_table.user_id + -> Index Scan using is_index1_1400256 on users_table_1400256 users_table +(22 rows) -- Grouping can be pushed down with aggregates even when window function can't EXPLAIN (COSTS FALSE) diff --git a/src/test/regress/expected/window_functions_0.out b/src/test/regress/expected/window_functions_0.out index aea319c0b..0a41bc0cc 100644 --- a/src/test/regress/expected/window_functions_0.out +++ b/src/test/regress/expected/window_functions_0.out @@ -1382,15 +1382,16 @@ LIMIT 5; -> Task Node: host=localhost port=xxxxx dbname=regression -> Limit - -> Sort + -> Incremental Sort Sort Key: users_table.user_id, (avg(users_table.value_1)) DESC + Presorted Key: users_table.user_id -> WindowAgg -> Sort Sort Key: users_table.user_id, (('1'::numeric / ('1'::numeric + avg(users_table.value_1)))) -> HashAggregate Group Key: users_table.user_id, users_table.value_2 -> Seq Scan on users_table_1400256 users_table -(17 rows) +(18 rows) EXPLAIN (COSTS FALSE) SELECT @@ -1413,15 +1414,16 @@ LIMIT 5; -> Task Node: host=localhost port=xxxxx dbname=regression -> Limit - -> Sort + -> Incremental Sort Sort Key: users_table.user_id, (avg(users_table.value_1)) DESC + Presorted Key: users_table.user_id -> WindowAgg -> Sort Sort Key: users_table.user_id, (('1'::numeric / ('1'::numeric + avg(users_table.value_1)))) -> HashAggregate Group Key: users_table.user_id, users_table.value_2 -> Seq Scan on users_table_1400256 users_table -(17 rows) +(18 rows) EXPLAIN (COSTS FALSE) SELECT @@ -1444,15 +1446,16 @@ LIMIT 5; -> Task Node: host=localhost port=xxxxx dbname=regression -> Limit - -> Sort + -> Incremental Sort Sort Key: users_table.user_id, (avg(users_table.value_1)) DESC + Presorted Key: users_table.user_id -> WindowAgg -> Sort Sort Key: users_table.user_id, ((1 / (1 + sum(users_table.value_2)))) -> HashAggregate Group Key: users_table.user_id, users_table.value_2 -> Seq Scan on users_table_1400256 users_table -(17 rows) +(18 rows) EXPLAIN (COSTS FALSE) SELECT @@ -1475,15 +1478,16 @@ LIMIT 5; -> Task Node: host=localhost port=xxxxx dbname=regression -> Limit - -> Sort + -> Incremental Sort Sort Key: users_table.user_id, (avg(users_table.value_1)) DESC + Presorted Key: users_table.user_id -> WindowAgg -> Sort Sort Key: users_table.user_id, (sum(users_table.value_2)) -> HashAggregate Group Key: users_table.user_id, users_table.value_2 -> Seq Scan on users_table_1400256 users_table -(17 rows) +(18 rows) -- Grouping can be pushed down with aggregates even when window function can't EXPLAIN (COSTS FALSE)