Resetting Key Parameters During SQL Tuning

This section introduces key parameters of the primary database node that affect optimization of SQL statements in openGauss. For details about the parameter configurations, see Configuring Running Parameters.

Table 1 Parameters of the primary database node

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 (that is, the current session), execute the following SQL statement:

SET enable_nestloop to off;

By default, this parameter is set to on. Change the value as required. Generally, nested loop join has the poorest performance among the three JOIN methods (nested loop join, merge join, and hash join). You are advised to set this parameter to off.

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 (that is, the current session), execute the following SQL statement:

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 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_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 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 LAZY_AGG and MAGIC_SET rewriting rules.

sql_beta_feature

Determines whether the optimizer enables the SEL_SEMI_POISSON, SEL_EXPR_INSTR, PARAM_PATH_GEN, RAND_COST_OPT, PARAM_PATH_OPT, PAGE_EST_OPT, CANONICAL_PATHKEY, PARTITION_OPFUSION, PREDPUSH_SAME_LEVEL, PARTITION_FDW_ON, DISABLE_BITMAP_COST_WITH_LOSSY_PAGES beta features.

var_eq_const_selectivity

<, a>Determines whether the optimizer uses histograms to calculate the integer constant selection rate.

partition_page_estimation

Determines whether to optimize the estimation of partitioned table page based on the pruning result. Only the partitioned table page and local index page are included, and the global index page is not included. The estimation formula is:

Number of pages after estimation = Number of pages in the partitioned table x (Number of partitions after pruning/Number of partitions)

partition_iterator_elimination

Determines whether to eliminate the partition iteration operator to improve execution efficiency when the partition pruning result of a partitioned table is a partition.

enable_functional_dependency

Determines whether to use the functional dependency statistics.

If the value is **on**:

  1. The statistics about multiple columns generated by ANALYZE contain functional dependency statistics.
  2. Functional dependency statistics are used to calculate the selection rate.
If

If the value is **off**:

  1. The statistics about multiple columns generated by ANALYZE do not contain functional dependency statistics.
  2. Functional dependency statistics are not used to calculate the selection rate.
description:

The concept of functional dependency comes from the relational database normal form, indicating the functional relationship between attributes. The concept of functional dependency statistics extends the preceding concept. It indicates the ratio of the data volume that meets the functional relationship to the total data volume. Functional dependency statistics are a type of multi-column statistics, which can be used to improve the accuracy of selection rate estimation.

Functional dependency statistics are applicable to the "where a = 1 and b = 1" format. The a and b must be attributes of the same table. The constraint is an equation constraint. The constraint is connected by AND. There are at least two constraints.

enable_seqscan_fusion

Determines whether to enable seqscan background noise elimination.

Feedback
编组 3备份
    openGauss 2024-07-20 01:00:34
    cancel