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.
Parameter 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.
- normal: default session, which is the same as the original behavior. The plan is executed based on the original logic of the database.
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.
Setting suggestion: Retain the default value.
Risks and impacts of improper settings: 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.
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.
Parameter type: string.
Unit: none
Value range: names of all DNs in the current cluster. You can obtain the names of all DNs by querying the PGXC_NODE system catalog.
Default value: ""
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.
Setting suggestion: Retain the default value.
Risks and impacts of improper settings: In single-node session mode, if the parameters are not used according to the restrictions, data inconsistency may occur.

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;
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot