From db4da8fe20ab7b8c336858794ca2ae3939f804ba Mon Sep 17 00:00:00 2001 From: wanghao19920907 Date: Sun, 28 May 2023 21:16:40 -0700 Subject: [PATCH 1/3] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=BC=80=E5=90=AF=E5=90=91=E9=87=8F=E5=8C=96=E5=AF=B9=E5=90=91?= =?UTF-8?q?=E9=87=8F=E5=8C=96=E8=AE=A1=E5=88=92=E4=B8=AD=E7=9A=84targetlis?= =?UTF-8?q?t=E8=BF=9B=E8=A1=8C=E5=89=AA=E8=A3=81=EF=BC=8C=E5=8F=AA?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E4=BD=BF=E7=94=A8=E5=88=B0=E5=88=97=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E9=99=8D=E4=BD=8E=E8=A1=8C=E8=BD=AC=E5=88=97=E6=97=B6?= =?UTF-8?q?=E5=80=99=E7=9A=84=E5=BC=80=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/utils/misc/guc/guc_sql.cpp | 27 +++++++++++++++++-- src/gausskernel/optimizer/plan/createplan.cpp | 5 +++- src/gausskernel/optimizer/plan/planner.cpp | 5 +++- .../knl/knl_guc/knl_session_attr_sql.h | 1 + .../regress/output/recovery_2pc_tools.source | 1 + 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/common/backend/utils/misc/guc/guc_sql.cpp b/src/common/backend/utils/misc/guc/guc_sql.cpp index cbb1b8ccc..bdc82ceec 100755 --- a/src/common/backend/utils/misc/guc/guc_sql.cpp +++ b/src/common/backend/utils/misc/guc/guc_sql.cpp @@ -188,7 +188,7 @@ static bool check_snapshot_delimiter(char** newval, void** extra, GucSource sour static bool check_snapshot_separator(char** newval, void** extra, GucSource source); static bool check_sql_ignore_strategy(char** newval, void** extra, GucSource source); static void assign_sql_ignore_strategy(const char* newval, void* extra); - +static void strategy_assign_vector_targetlist(int newval, void* extra); static void InitSqlConfigureNamesBool(); static void InitSqlConfigureNamesInt(); @@ -1727,6 +1727,18 @@ static void InitSqlConfigureNamesBool() NULL, NULL}, #endif + {{"enable_vector_targetlist", + PGC_USERSET, + NODE_ALL, + QUERY_TUNING_OTHER, + gettext_noop("enable vector targetlist for row to vector."), + NULL}, + &u_sess->attr.attr_sql.enable_vector_targetlist, + false, + NULL, + NULL, + NULL + }, /* End-of-list marker */ {{NULL, (GucContext)0, @@ -3054,7 +3066,7 @@ static void InitSqlConfigureNamesEnum() OFF_VECTOR_ENGINE, vector_engine_strategy, NULL, - NULL, + strategy_assign_vector_targetlist, NULL}, {{"multi_stats_type", PGC_USERSET, @@ -4136,3 +4148,14 @@ static void assign_sql_ignore_strategy(const char* newval, void* extra) { } u_sess->utils_cxt.sql_ignore_strategy_val = sql_ignore_strategy[0].val; } + +static void strategy_assign_vector_targetlist(int newval, void* extra) +{ + if (newval == FORCE_VECTOR_ENGINE || newval == OPT_VECTOR_ENGINE) + u_sess->attr.attr_sql.enable_vector_targetlist = true; + else { + u_sess->attr.attr_sql.enable_vector_targetlist = false; + } + + return; +} diff --git a/src/gausskernel/optimizer/plan/createplan.cpp b/src/gausskernel/optimizer/plan/createplan.cpp index 932a85b25..a7a19c5e7 100755 --- a/src/gausskernel/optimizer/plan/createplan.cpp +++ b/src/gausskernel/optimizer/plan/createplan.cpp @@ -4860,7 +4860,10 @@ static HashJoin* create_hashjoin_plan(PlannerInfo* root, HashPath* best_path, Pl disuse_physical_tlist(inner_plan, best_path->jpath.innerjoinpath); /* If we expect batching, suppress excess columns in outer tuples too */ - if (best_path->num_batches > 1) + if (best_path->num_batches > 1 || + (u_sess->attr.attr_sql.enable_vector_engine && + u_sess->attr.attr_sql.vectorEngineStrategy != OFF_VECTOR_ENGINE && + u_sess->attr.attr_sql.enable_vector_targetlist)) disuse_physical_tlist(outer_plan, best_path->jpath.outerjoinpath); /* diff --git a/src/gausskernel/optimizer/plan/planner.cpp b/src/gausskernel/optimizer/plan/planner.cpp index 38a2276ef..5a6f0e4be 100755 --- a/src/gausskernel/optimizer/plan/planner.cpp +++ b/src/gausskernel/optimizer/plan/planner.cpp @@ -3418,7 +3418,10 @@ static Plan* grouping_planner(PlannerInfo* root, double tuple_fraction) * * We don't want any excess columns for hashagg, since we support hashagg write-out-to-disk now */ - if (use_hashed_grouping) + if (use_hashed_grouping || + (u_sess->attr.attr_sql.enable_vector_engine && + u_sess->attr.attr_sql.vectorEngineStrategy != OFF_VECTOR_ENGINE && + u_sess->attr.attr_sql.enable_vector_targetlist)) disuse_physical_tlist(result_plan, best_path); locate_grouping_columns(root, tlist, result_plan->targetlist, groupColIdx); diff --git a/src/include/knl/knl_guc/knl_session_attr_sql.h b/src/include/knl/knl_guc/knl_session_attr_sql.h index f4b3af22d..10823912c 100644 --- a/src/include/knl/knl_guc/knl_session_attr_sql.h +++ b/src/include/knl/knl_guc/knl_session_attr_sql.h @@ -254,6 +254,7 @@ typedef struct knl_session_attr_sql { bool enable_custom_parser; bool dolphin; bool whale; + bool enable_vector_targetlist; #endif } knl_session_attr_sql; diff --git a/src/test/regress/output/recovery_2pc_tools.source b/src/test/regress/output/recovery_2pc_tools.source index 6bf0da51e..e7fb7dc10 100644 --- a/src/test/regress/output/recovery_2pc_tools.source +++ b/src/test/regress/output/recovery_2pc_tools.source @@ -329,6 +329,7 @@ select name,vartype,unit,min_val,max_val from pg_settings where name <> 'qunit_c enable_ustore | bool | | | enable_valuepartition_pruning | bool | | | enable_vector_engine | bool | | | + enable_vector_targetlist | bool | | | enable_wal_shipping_compression | bool | | | enable_wdr_snapshot | bool | | | enable_xlog_prune | bool | | | From 2366d70dc94cca06b74a655670a488506088b529 Mon Sep 17 00:00:00 2001 From: wanghao19920907 Date: Sun, 28 May 2023 23:35:25 -0700 Subject: [PATCH 2/3] fixbug for regress --- src/test/regress/output/recovery_2pc_tools.source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/regress/output/recovery_2pc_tools.source b/src/test/regress/output/recovery_2pc_tools.source index e7fb7dc10..65b0e4c7c 100644 --- a/src/test/regress/output/recovery_2pc_tools.source +++ b/src/test/regress/output/recovery_2pc_tools.source @@ -329,7 +329,7 @@ select name,vartype,unit,min_val,max_val from pg_settings where name <> 'qunit_c enable_ustore | bool | | | enable_valuepartition_pruning | bool | | | enable_vector_engine | bool | | | - enable_vector_targetlist | bool | | | + enable_vector_targetlist | bool | | | enable_wal_shipping_compression | bool | | | enable_wdr_snapshot | bool | | | enable_xlog_prune | bool | | | From 17f82f33cda57c6b46e37ab461959d17b06195d6 Mon Sep 17 00:00:00 2001 From: wanghao19920907 Date: Mon, 29 May 2023 05:43:19 -0700 Subject: [PATCH 3/3] fixbug --- .../regress/expected/force_vector_engine2.out | 4 +- .../row_partition_iterator_elimination.out | 40 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/test/regress/expected/force_vector_engine2.out b/src/test/regress/expected/force_vector_engine2.out index 307726bfc..99b3a9456 100644 --- a/src/test/regress/expected/force_vector_engine2.out +++ b/src/test/regress/expected/force_vector_engine2.out @@ -103,8 +103,8 @@ select id,operation,options,object_name,object_type,projection from plan_table o ----+--------------------------------+----------+-------------------+-------------+----------------------------------- 1 | ROW ADAPTER | | | | e.empno, e.ename, e.sal, d.dname 2 | VECTOR SONIC HASH JOIN | INNER | | | e.empno, e.ename, e.sal, d.dname - 3 | VECTOR ADAPTER(TYPE: BATCH MOD | | | | d.deptno, d.dname, d.loc - 4 | TABLE ACCESS | SEQ SCAN | force_vector_dept | TABLE | d.deptno, d.dname, d.loc + 3 | VECTOR ADAPTER(TYPE: BATCH MOD | | | | d.dname, d.deptno + 4 | TABLE ACCESS | SEQ SCAN | force_vector_dept | TABLE | d.dname, d.deptno 5 | VECTOR ADAPTER(TYPE: BATCH MOD | | | | e.empno, e.ename, e.sal, e.deptno 6 | TABLE ACCESS | SEQ SCAN | force_vector_emp | TABLE | e.empno, e.ename, e.sal, e.deptno (6 rows) diff --git a/src/test/regress/expected/row_partition_iterator_elimination.out b/src/test/regress/expected/row_partition_iterator_elimination.out index b83470b18..ffe6bf18e 100644 --- a/src/test/regress/expected/row_partition_iterator_elimination.out +++ b/src/test/regress/expected/row_partition_iterator_elimination.out @@ -2299,10 +2299,10 @@ explain(costs off, verbose on) select count(a) from test_hash_ht where a = 30; -> Vector Aggregate Output: count(a) -> Vector Adapter(type: BATCH MODE) - Output: a, b, c, d + Output: a Filter: (test_hash_ht.a = 30) -> Partitioned Seq Scan on row_partition_iterator_elimination.test_hash_ht - Output: a, b, c, d + Output: a Selected Partitions: 17 (10 rows) @@ -2314,10 +2314,10 @@ explain(costs off, verbose on) select count(b) from test_hash_ht where a = 30; -> Vector Aggregate Output: count(b) -> Vector Adapter(type: BATCH MODE) - Output: a, b, c, d + Output: b Filter: (test_hash_ht.a = 30) -> Partitioned Seq Scan on row_partition_iterator_elimination.test_hash_ht - Output: a, b, c, d + Output: b Selected Partitions: 17 (10 rows) @@ -2345,10 +2345,10 @@ explain(costs off, verbose on) select count(a) from test_range_pt where a = 30; -> Vector Aggregate Output: count(a) -> Vector Adapter(type: BATCH MODE) - Output: a, b, c, d + Output: a Filter: (test_range_pt.a = 30) -> Partitioned Seq Scan on row_partition_iterator_elimination.test_range_pt - Output: a, b, c, d + Output: a Selected Partitions: 3 (10 rows) @@ -2360,10 +2360,10 @@ explain(costs off, verbose on) select count(b) from test_range_pt where a = 30; -> Vector Aggregate Output: count(b) -> Vector Adapter(type: BATCH MODE) - Output: a, b, c, d + Output: b Filter: (test_range_pt.a = 30) -> Partitioned Seq Scan on row_partition_iterator_elimination.test_range_pt - Output: a, b, c, d + Output: b Selected Partitions: 3 (10 rows) @@ -2580,9 +2580,9 @@ explain(costs off, verbose on) select count(b) from test_hash_ht where a = 30; -> Vector Aggregate Output: count(b) -> Vector Adapter - Output: a, b, c, d + Output: b -> Partitioned Index Scan using idx_hash_local on row_partition_iterator_elimination.test_hash_ht - Output: a, b, c, d + Output: b Index Cond: (test_hash_ht.a = 30) Selected Partitions: 17 (10 rows) @@ -2626,9 +2626,9 @@ explain(costs off, verbose on) select count(b) from test_range_pt where a = 30; -> Vector Aggregate Output: count(b) -> Vector Adapter - Output: a, b, c, d + Output: b -> Partitioned Index Scan using idx_range_local on row_partition_iterator_elimination.test_range_pt - Output: a, b, c, d + Output: b Index Cond: (test_range_pt.a = 30) Selected Partitions: 3 (10 rows) @@ -2834,9 +2834,9 @@ explain(costs off, verbose on) select count(a) from test_hash_ht where a = 30; -> Vector Aggregate Output: count(a) -> Vector Adapter - Output: a, b, c, d + Output: a -> Partitioned Bitmap Heap Scan on row_partition_iterator_elimination.test_hash_ht - Output: a, b, c, d + Output: a Recheck Cond: (test_hash_ht.a = 30) Selected Partitions: 17 -> Partitioned Bitmap Index Scan on idx_hash_local @@ -2852,9 +2852,9 @@ explain(costs off, verbose on) select count(b) from test_hash_ht where a = 30; -> Vector Aggregate Output: count(b) -> Vector Adapter - Output: a, b, c, d + Output: b -> Partitioned Bitmap Heap Scan on row_partition_iterator_elimination.test_hash_ht - Output: a, b, c, d + Output: b Recheck Cond: (test_hash_ht.a = 30) Selected Partitions: 17 -> Partitioned Bitmap Index Scan on idx_hash_local @@ -2889,9 +2889,9 @@ explain(costs off, verbose on) select count(a) from test_range_pt where a = 30; -> Vector Aggregate Output: count(a) -> Vector Adapter - Output: a, b, c, d + Output: a -> Partitioned Bitmap Heap Scan on row_partition_iterator_elimination.test_range_pt - Output: a, b, c, d + Output: a Recheck Cond: (test_range_pt.a = 30) Selected Partitions: 3 -> Partitioned Bitmap Index Scan on idx_range_local @@ -2907,9 +2907,9 @@ explain(costs off, verbose on) select count(b) from test_range_pt where a = 30; -> Vector Aggregate Output: count(b) -> Vector Adapter - Output: a, b, c, d + Output: b -> Partitioned Bitmap Heap Scan on row_partition_iterator_elimination.test_range_pt - Output: a, b, c, d + Output: b Recheck Cond: (test_range_pt.a = 30) Selected Partitions: 3 -> Partitioned Bitmap Index Scan on idx_range_local