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

Configuring Key Parameters for SQL Optimization

This section describes key configuration parameters of the primary database node, which affect GaussDB SQL optimization.

Table 1 Parameters of the primary database node

Parameter/Reference Value

Description

enable_nestloop=off

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

NOTE:

To temporarily change the value of this parameter for the current database connection (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:

To temporarily change the value of this parameter for the current database connection (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 scanning. If the value is on, bitmap scanning is used. If the value is off, it is not used.

NOTE:

To temporarily change the value of this parameter for the current database connection (session), execute the following SQL statement:

1
SET enable_bitmapscan to off;

The bitmap scanning applies only in the query condition where a > 1 and b > 1 and indexes are created on columns a and b. 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_hashagg=on

Specifies whether to enable the optimizer's use of Hash-aggregation plan types.

enable_hashjoin=on

Specifies whether to enable the optimizer's use of Hash-join plan types.

enable_mergejoin=on

Specifies whether to enable the optimizer's use of Hash-merge plan types.

enable_indexscan=on

Specifies whether the optimizer uses index scan plans.

enable_indexonlyscan=on

Specifies whether the optimizer uses index-only scan plans.

enable_seqscan=on

Specifies whether the optimizer uses bitmap scanning. 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 sorts. It is impossible to fully suppress explicit sorts, but setting this variable to off allows the optimizer to preferentially choose other methods if available.

rewrite_rule

Specifies whether the optimizer enables the following rewriting rules: LAZYAGG, MAGICSET, UNIQUECHECK, INTARGETLIST, PREDPUSHNORMAL, PREDPUSHFORCE, PREDPUSH, DISABLE_PULLUP_EXPR_SUBLINK, DISABLE_PULLUP_NOT_IN_SUBLINK, and ENABLE_SUBLINK_PULLUP_ROWNUM.

sql_beta_feature

Specifies whether the optimizer enables the following beta features: SEL_SEMI_POISSON, SEL_EXPR_INSTR, PARAM_PATH_GEN, RAND_COST_OPT, PARAM_PATH_OPT, PAGE_EST_OPT, CANONICAL_PATHKEY, PREDPUSH_SAME_LEVEL, PARTITION_FDW_ON, and DISABLE_BITMAP_COST_WITH_LOSSY_PAGES.