Help Center/ GaussDB/ Developer Guide(Distributed_V2.0-8.x)/ SQL Optimization/ Configuring Key Parameters for SQL Optimization
Updated on 2025-08-19 GMT+08:00

Configuring Key Parameters for SQL Optimization

This section describes key CN configuration parameters that affect GaussDB SQL performance optimization. Contact an administrator to configure parameters.

Table 1 CN parameters

Parameter/Reference Value

Description

enable_nestloop=off

Specifies how the optimizer uses nested loop join. If the value is on, the optimizer preferentially uses nested loop Join. If it is set to off, the optimizer preferentially uses other methods, if any.

NOTE:

If you only want to temporarily change the value of this parameter during the current database connection (that is, the current session), execute the following SQL statement:

1
SET enable_nestloop to off;

Disabling this parameter does not affect the index nested-loop join operator (corresponding to the enable_index_nestloop parameter). During real-world optimization, it is important to assess whether to disable this parameter based on the specific circumstances. Three types of joins are supported: nested loops, merge joins, and hash joins. Specifically, nested loops are best suited for scenarios with small data volumes or indexes, while hash joins are ideal for big data analysis.

enable_index_nestloop=on

Specifies whether to enable the index nested-loop join operator.

NOTE:

If you only want to temporarily change the value of this parameter during the current database connection (that is, the current session), execute the following SQL statement:

1
SET enable_index_nestloop to off;

Differences between enable_index_nestloop and enable_nestloop: enable_index_nestloop helps manage scenarios where the inner table undergoes index scans, and the outer table supplies index condition parameters for the inner table.

enable_bitmapscan=on

Specifies whether the optimizer uses bitmap scan. If the value is on, bitmap scan is used. If the value is off, it is not used.

NOTE:

If you only want to temporarily change the value of this parameter during the current database connection (that is, the current session), execute the following SQL statement:

1
SET enable_bitmapscan to off;

The bitmap scan applies only in the query condition where a > 1 and b > 1 and indexes are created on columns a and b. However, the performance of bitmapscan is sometimes inferior to that of indexscan. During optimization, if the query performance is poor and bitmapscan operators are in the execution plan, set this parameter to off and check whether the performance is improved.

enable_fast_query_shipping=on

Specifies whether the optimizer uses a distribution framework to execute quick execution plans. If the value is on, the execution plan is generated on both CNs and DNs. If the value is off, the distribution framework is used, that is, the execution plan is generated on the CN and then sent to the DN for execution.

NOTE:

If you only want to temporarily change the value of this parameter during the current database connection (that is, the current session), execute the following SQL statement:

1
SET enable_fast_query_shipping to off;

enable_hashagg=on

Specifies whether the optimizer uses hash aggregate plans.

enable_hashjoin=on

Specifies whether the optimizer uses hash join plans.

enable_mergejoin=on

Specifies whether the optimizer uses merge join plans.

enable_indexscan=on

Specifies whether the optimizer uses index scan plans.

enable_gsitablescan=on

Specifies whether the optimizer uses GSI scan plans.

gsi_fastpath_level=strict

Specifies whether the optimizer executes the determination system of simple query rules of GSI. The simple query rules of GSI are as follows:
  • A single table, no subquery, no sublink, or the target table is not a view.
  • The query statement cannot generate an execution plan for an ordinary index.
  • The query statement cannot generate the IndexOnlyScan execution plan of GSI.
  • Query statements do not contain scan hints, such as tablescan and indexscan.
  • The WHERE condition contains an equivalent condition that contains the index key of the candidate GSI (unique and not a partial GSI index).

enable_indexonlyscan=on

Specifies whether the optimizer uses index-only scan plans.

enable_gsiscan=on

Specifies whether the optimizer uses GSI-only scan plans.

enable_seqscan=on

Specifies whether the optimizer uses sequential scan plans. It is impossible to suppress sequential scans entirely, but setting this variable to off encourages the optimizer to choose other methods if available.

enable_sort=on

Specifies the optimizer sorting order. It is impossible to fully suppress explicit sorting, but setting this variable to off encourages the optimizer to choose other methods if available.

enable_broadcast=on

Specifies whether the optimizer uses data broadcast. In data broadcast, a large amount of data is transferred on the network. When the number of transmission nodes (stream) is large and the estimation is inaccurate, set this parameter to off and check whether the performance is improved.

rewrite_rule

Specifies whether the optimizer enables the LAZYAGG, MAGICSET, PARTIALPUSH, DISABLEREP, UNIQUECHECK, INTARGETLIST, PREDPUSH, PREDPUSHFORCE, PREDPUSHNORMAL, DISABLE_PULLUP_EXPR_SUBLINK, ENABLE_SUBLINK_PULLUP_ENHANCED, DISABLE_PULLUP_NOT_IN_SUBLINK, DISABLE_ROWNUM_PUSHDOWN, DISABLE_WINDOWAGG_PUSHDOWN rewriting, or GROUPBY_PUSHDOWN_SUBQUERY rule.

sql_beta_feature

Specifies whether the optimizer enables the SEL_SEMI_POISSON, NO_UNIQUE_INDEX_FIRST, JOIN_SEL_WITH_CAST_FUNC, SEL_EXPR_INSTR, PARAM_PATH_GEN, RAND_COST_OPT, PARAM_PATH_OPT, PAGE_EST_OPT, CANONICAL_PATHKEY, INDEX_COST_WITH_INDEX_COST_WITH_LEAF_PAGES_ONLY, PREDPUSH_SAME_LEVEL, PARTITION_FDW_ON, DISABLE_BITMAP_COST_WITH_LOSSY_PAGES, or ENABLE_UPSERT_EXECUTE_GPLAN beta feature.

enable_inner_unique_opt

Specifies whether the optimizer uses Inner Unique.