Help Center> GaussDB> User Guide> Performance Tuning> SQL Tuning Guide> Resetting Key Parameters During SQL Tuning
Updated on 2024-01-12 GMT+08:00

Resetting Key Parameters During SQL Tuning

This section describes the key CN configuration parameters that affect the GaussDB SQL tuning performance.

Table 1 CN parameters

Parameter/Reference Value

Description

enable_nestloop=on

Specifies how the optimizer uses Nest Loop Join. If this parameter is set to on, the optimizer preferentially uses Nest 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 (or the current session), execute the following SQL statement:

SET enable_nestloop to off;

You can determine whether to disable this function based on the actual requirements. Generally, among the three join modes (Nested Loop, Merge Join, and Hash Join), Nested Loop is suitable for scenarios with small data volume or indexes, and Hash Join is suitable for big data analysis.

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:

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

SET enable_bitmapscan to off;

The bitmap scan applies only in the query condition where a > 1 and b > 1 is used and indexes are created on columns a and b. It sometimes does not perform as well as index scan. During performance tuning, 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. If its value is on, the execution plan is generated on both CNs and DNs. If the value is off, the distribution framework is used. The execution plan is generated on CNs and then sent to DNs for execution.

NOTE:

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

SET enable_fast_query_shipping to off;

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 to enable the optimizer's use of index scan plan types.

enable_indexonlyscan=on

Specifies whether to enable the optimizer's use of index-only scan plan types.

enable_seqscan=on

Specifies whether to enable the optimizer's use of sequential scan plan types. It is impossible to completely suppress sequential scans, but setting this parameter to off allows 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 parameter to off allows the optimizer to preferentially choose other methods if available.

enable_broadcast=on

Specifies whether to enable the optimizer's use of 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, UNIQUECHECK, DISABLEREP, INTARGETLIST, and PREDPUSH rewriting rules.