diff --git a/src/common/backend/utils/misc/guc/guc_sql.cpp b/src/common/backend/utils/misc/guc/guc_sql.cpp index abc55fc2a..8aff4a3b1 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(); @@ -1749,6 +1749,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, @@ -3076,7 +3088,7 @@ static void InitSqlConfigureNamesEnum() OFF_VECTOR_ENGINE, vector_engine_strategy, NULL, - NULL, + strategy_assign_vector_targetlist, NULL}, {{"multi_stats_type", PGC_USERSET, @@ -4158,3 +4170,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 86f7ffff9..e9f074ab5 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 b603dbb07..ff4b0af06 100755 --- a/src/gausskernel/optimizer/plan/planner.cpp +++ b/src/gausskernel/optimizer/plan/planner.cpp @@ -3431,7 +3431,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 3ae9e0fe5..6a5d043f3 100644 --- a/src/include/knl/knl_guc/knl_session_attr_sql.h +++ b/src/include/knl/knl_guc/knl_session_attr_sql.h @@ -255,6 +255,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/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 diff --git a/src/test/regress/output/recovery_2pc_tools.source b/src/test/regress/output/recovery_2pc_tools.source index 40bc22c02..21e1cb114 100644 --- a/src/test/regress/output/recovery_2pc_tools.source +++ b/src/test/regress/output/recovery_2pc_tools.source @@ -331,6 +331,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 | | |