Help Center/ GaussDB/ Developer Guide(Distributed_8.x)/ Configuring GUC Parameters/ GUC Parameters/ Session-level Transaction Pushdown and Related Parameters
Updated on 2024-06-03 GMT+08:00

Session-level Transaction Pushdown and Related Parameters

session_type

Parameter description: Specifies the type of the current session. The value is case insensitive. An execution plan is generated based on the actual value.

Value type: enumerated type

Unit: none

Value range:

  • single_node: single-node session. Read and write operations can be pushed down. Nodes to be pushed down are determined and an execution plan is generated based on the GUC parameter exec_target_node.
  • global_read_only: cross-node read-only session. A distributed plan is generated normally, but distributed write operations are forbidden. The GUC parameter exec_target_node does not take effect.
  • normal: default session, which is the same as the original behavior. The plan is executed based on the original logic of the database.

When data is inserted in single-node session mode (session_type is set to single_node), correct data distribution is ensured by the application layer. If an incorrect node is specified, data may be inconsistent.

Default value: normal

Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 2. Note that this parameter cannot be set globally using gs_guc.

exec_target_node

Parameter description: Specifies the name of the DN where DML statements and some DDL statements (TRUNCATE and ALTER TABLE...TRUNCATE PARTITION...) of the current session are executed. The name is case sensitive. If the DN name is invalid, an error is reported during the setting.

This parameter is valid only when the GUC parameter session_type is set to single_node.

Parameter type: string

Unit: none

Value range: names of all DNs in the current cluster.

Default value: NULL

Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 2. Note that this parameter cannot be set globally using gs_guc.

The single-node session mode has the following restrictions:

  • The router function does not take effect in this scenario.
  • The DN specified by node_name hint does not take effect and is delivered by exec_target_node.
  • Statements involving row-level security are not supported.
  • Reading on the distributed standby node is not supported.
  • Advanced package statements are not supported.
  • GPC is not supported. When the enable_global_plancache parameter is enabled, if PBE is executed, an error is reported.
  • In single-node session mode, when the PBE statement is used, the plan type is directly set to GPlan. If the single-node session mode is specified after a plan is generated, the original plan type remains unchanged.

Examples

gaussdb=# set log_min_messages = debug2;
gaussdb=# set logging_module = 'on(opt_choice)';
gaussdb=# create table t1(a int ,b int);
gaussdb=# prepare x(int) as select * from t1;
gaussdb=# explain execute x(10);
NOTICE:  [Choosing C/G/A Plan]: GPlan, reason: Using pbe optimization.
NOTICE:  [Choosing C/G/A Plan]: CPlan, reason: First 5 times using CPlan.
                    QUERY PLAN                    
--------------------------------------------------
 Data Node Scan  (cost=0.00..0.00 rows=0 width=0)
   Node/s: All datanodes
(2 rows)
gaussdb=# DEALLOCATE x;
gaussdb=# prepare x(int) as select * from t1;
gaussdb=# set session_type=single_node;
gaussdb=# set exec_target_node=datanode1;
gaussdb=# explain execute x(10);
NOTICE:  [Choosing C/G/A Plan]: GPlan, reason: Using pbe optimization.
NOTICE:  [Choosing C/G/A Plan]: GPlan, reason: Using pbe optimization.
                    QUERY PLAN                    
--------------------------------------------------
 Data Node Scan  (cost=0.00..0.00 rows=0 width=0)
   Node/s: datanode1
(2 rows)
gaussdb=# DEALLOCATE x;
gaussdb=# drop table t1;