Updated on 2024-06-03 GMT+08:00

Optimizer Method Configuration

These configuration parameters provide a crude method of influencing the query plans chosen by the query optimizer. If the default plan chosen by the optimizer for a particular query is not optimal, a temporary solution is to use one of these configuration parameters to force the optimizer to choose a different plan. Better ways include adjusting the optimizer cost constants, manually running ANALYZE, increasing the value of the default_statistics_target parameter, and increasing the amount of the statistics collected in specific columns using ALTER TABLE SET STATISTICS.

enable_bitmapscan

Parameter description: Specifies whether the optimizer uses bitmap-scan plan types.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: After this function is disabled, the bitmap scan operator is disabled globally, which may cause performance deterioration in some scenarios. Exercise caution when modifying the parameter to avoid risks caused by misoperations.

force_bitmapand

Parameter description: Specifies whether the query optimizer forcibly uses BitmapAnd plan types.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: off

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_hashagg

Parameter description: Specifies whether the optimizer uses hash aggregation plan types.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_hashjoin

Parameter description: Specifies whether the optimizer uses hash join plan types.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_indexscan

Parameter description: Specifies whether the optimizer uses index-scan plan types.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_gsitablescan

Parameter description: Specifies whether the query optimizer uses the global secondary index table scan plan types.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: Retain the default value.

enable_indexonlyscan

Parameter description: Specifies whether the optimizer uses index-only-scan plan types.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_gsiscan

Parameter description: Specifies whether the query optimizer uses global secondary-index-only scan plan types.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_material

Parameter description: Specifies whether the query optimizer uses materialization. It is impossible to suppress materialization entirely, but setting this variable to off prevents the optimizer from inserting materialized nodes.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_mergejoin

Parameter description: Specifies whether the optimizer uses merge-join plan types.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: off

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: Retain the default value.

enable_nestloop

Parameter description: Specifies whether the query optimizer uses nested-loop join plan types to fully scan internal tables. It is impossible to suppress nested-loop joins entirely, but setting this variable to off encourages the optimizer to choose other methods if available.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: off

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: Retain the default value.

enable_index_nestloop

Parameter description: Specifies whether the optimizer uses the nested-loop join plan type to scan the parameterized indexes of inner tables.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_seqscan

Parameter description: Specifies whether the query optimizer uses sequential scan plan types. It is impossible to suppress sequential scans entirely, but setting this variable to off encourages the optimizer to choose other methods if available.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: Retain the default value.

Risks and impacts of improper settings: none

enable_sort

Parameter description: Specifies whether the query optimizer uses sort methods. It is impossible to suppress explicit sorts entirely, but setting this variable to off encourages the optimizer to choose other methods if available.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_tidscan

Parameter description: Specifies whether the optimizer uses Tuple ID (TID) scan plan types.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_kill_query

Parameter description: In CASCADE mode, when a user is deleted, all the objects belonging to the user are deleted. This parameter specifies whether the queries of the objects belonging to the user can be unlocked when the user is deleted.

Parameter type: Boolean.

Unit: none

Value range:

  • on indicates that the unlocking is allowed.
  • off indicates that the unlocking is not allowed.

Default value: off

Setting method: This is a SUSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_stream_concurrent_update

Parameter description: Specifies the optimizer's use of streams in concurrent update scenarios. This parameter is restricted by the enable_stream_operator parameter. If concurrent update conflicts occur, an error may be reported. This parameter can be used to control the conflict.

Parameter type: Boolean.

Unit: none

Value range:

  • on indicates that the optimizer can generate stream plans for the UPDATE statement.
  • off indicates that the optimizer can generate only non-stream plans for the UPDATE statement.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_stream_operator

Parameter description: Specifies whether the optimizer uses stream. When the enable_stream_operator parameter is disabled, a large number of logs indicating that the stream plans cannot be pushed down are recorded. If you do not need these logs, you are advised to disable enable_unshipping_log when disabling enable_stream_operator.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.
Default value:
  • Independent deployment: off

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: Retain the default value.

enable_stream_recursive

Parameter description: Specifies whether to push WITH RECURSIVE join queries to DNs for processing.

Parameter type: Boolean.

Unit: none

Value range:

  • on indicates that WITH RECURSIVE join queries will be pushed down to DNs.
  • off indicates that WITH RECURSIVE join queries will not be pushed down.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

max_recursive_times

Parameter description: Specifies the maximum number of WITH RECURSIVE iterations.

Parameter type: integer.

Unit: none

Value range: 0 to 2147483647

Default value: 200

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: This parameter is used to prevent an infinite loop of the with recursive statement by using nocycle in hierarchical queries to exit the loop. If you want to adjust the value, make sure you understand the parameter meaning and adjust the value with caution to avoid risks caused by misoperations.

enable_broadcast

Parameter description: Specifies whether the query optimizer uses broadcast distribution method when it evaluates the cost of stream.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_change_hjcost

Parameter description: Specifies whether the optimizer excludes inner table running costs when selecting the Hash Join cost path. If it is set to on, tables with a few records and high running costs are more possible to be selected.

Parameter type: Boolean.

Unit: none

Value range:

  • on: used.
  • off: not used.

Default value: off

Setting method: This is a SUSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

best_agg_plan

Parameter description: Specifies the type of hash aggregation plan generated by the optimizer. The optimizer can generate three plans for the aggregation operation in a stream:
  • hashagg+gather(redistribute)+hashagg
  • redistribute+hashagg(+gather)
  • hashagg+redistribute+hashagg(+gather)

Parameter type: integer.

Unit: none

Value range: 0 to 3.

  • 0: The optimizer generates the optimal plan based on the estimated costs of the three plans.
  • 1: The first plan is forcibly generated.
  • 2: The second plan is forcibly generated if the group by column can be redistributed. Otherwise, the first plan is generated.
  • 3: The third plan is forcibly generated if the group by column can be redistributed. Otherwise, the first plan is generated.

Default value: 0

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

agg_redistribute_enhancement

Parameter description: When the aggregate operation is performed, which contains multiple group by columns and all of the columns are not in the distribution column, you need to select one group by column for redistribution. This parameter specifies the policy of selecting a redistribution column.

Parameter type: Boolean.

Unit: none

Value range:

  • on: The column that can be redistributed with the most distinct value evaluated is selected for redistribution.
  • off: The first column that can be redistributed is selected for redistribution.

Default value: off

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_absolute_tablespace

Parameter description: Specifies whether the tablespace can use the absolute path.

Parameter type: Boolean.

Unit: none

Value range:

  • on: An absolute path can be used.
  • off: No absolute path can be used.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_valuepartition_pruning

Parameter description: Specifies whether the DFS partitioned table is dynamically or statically optimized.

Parameter type: Boolean.

Unit: none

Value range:

  • on: The DFS partitioned table is dynamically or statically optimized.
  • off: The DFS partitioned table is not dynamically or statically optimized.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

expected_computing_nodegroup

Parameter description: Specifies a compute node group or the way to choose such a group. The node group mechanism is internal. You do not need to set it. During join or aggregation operations, a node group can be selected in four modes. In each mode, the specified candidate compute node groups are listed for the optimizer to select the most appropriate one for the current operator.

Parameter type: string.

Unit: none

Value range:

  • optimal: The list of candidate compute node groups consists of the node groups where the operator's operation objects are located and the node group that combines all DNs in the node groups on which the current user has the COMPUTE permission.
  • query: The list of candidate compute node groups consists of the node groups where the operator's operation objects are located and the node group that combines all DNs in the node groups where base tables involved in the query are located.
  • Node group name (when enable_nodegroup_debug is set to off): The list of candidate compute node groups consists of the node groups where the operator's operation objects are located and the specified node group.
  • Node group name (when enable_nodegroup_debug is set to on): A specific node group is used as the compute node group.

Default value: query

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_nodegroup_debug

Parameter description: Specifies whether the optimizer assigns computing workloads to a specific node group when multiple node groups exist in an environment. The node group mechanism is internal. You do not need to set it. This parameter takes effect only when expected_computing_nodegroup is set to a specific node group.

Parameter type: Boolean.

Unit: none

Value range:

  • on: Computing workloads are assigned to the node group specified by expected_computing_nodegroup.
  • off: No node group is specified for computing.

Default value: off

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_default_index_deduplication

Parameter description: Specifies whether to deduplicate and compress tuples with duplicate key values for a B-tree index by default. The deduplication and compression functions do not take effect for primary key indexes and unique indexes. When there are a large number of indexes with duplicate key values, the deduplication and compression function can effectively reduce the space occupied by indexes. In scenarios where non-unique indexes are used and index key values are seldom repeated or unique, the deduplication and compression function slightly deteriorates the index insertion performance. If the WITH (deduplication set to on/off) syntax is used during index creation, the deduplication parameter is preferentially used to determine whether to use deduplication and compression for the index.

Parameter type: Boolean.

Unit: none

Value range:

  • off: The deduplication and compression function is disabled for B-tree indexes.
  • on: The deduplication and compression function is enabled for B-tree indexes.

Default value: off

Setting method: This is a POSTMASTER parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_expr_fusion

Parameter description: Specifies whether to enable the SRF, expression flattening, centralized Seq Scan projection cancellation, transition status of shared aggregate functions, and step number optimization features.

Parameter type: Boolean.

Unit: none

Value range:

  • on: The SRF, expression flattening, centralized Seq Scan projection cancellation, transition status of shared aggregate functions, and step number optimization features are enabled.
  • off: disabled.

Default value: off

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

The SRF supports only the scenario where query_dop is set to 1.

stream_multiple

Parameter description: Specifies the weight used by the optimizer to calculate the final cost of stream operators. The base stream cost is multiplied by this weight to obtain the final cost.

This parameter is applicable only to Redistribute and Broadcast streams.

Parameter type: floating-point.

Unit: none

Value range: 0 to DBL_MAX

Default value: 1

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

qrw_inlist2join_optmode

Parameter description: Specifies whether to enable inlist-to-join (inlist2join) query rewriting.

Parameter type: string.

Unit: none

Value range:

  • disable indicates that the inlist2join query rewriting is disabled.
  • cost_base indicates that the cost-based inlist2join query rewriting is enabled.
  • rule_base indicates that the forcible rule-based inlist2join query rewriting is enabled.
  • A positive integer (1 to 2147483647) indicates the threshold of inlist2join query rewriting. If the number of elements in the list is greater than the threshold, the rewriting is performed.

Default value: cost_base

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: Retain the default value.

skew_option

Parameter description: Specifies whether an optimization policy is used.

Value type: enumerated type.

Unit: none

Value range: off, normal, and lazy

  • off indicates that the policy is disabled.
  • normal indicates that a radical policy is used. All possible skews are optimized.
  • lazy indicates that a conservative policy is used. Uncertain skews are ignored.

Default value: normal

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_dngather

Parameter description: Specifies whether to calculate stream plans that meet the threshold on a single DN to reduce the number of planned stream nodes.

Parameter type: Boolean.

Unit: none

Value range:

  • on: enable.
  • off: disabled.

Default value: off

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

dngather_min_rows

Parameter description: Specifies the maximum number of rows that control dngather. Values less than or equal to this parameter value can be calculated on a single DN. The prerequisite is that enable_dngather is enabled.

Parameter type: floating-point.

Unit: none

Value range: –1 to DBL_MAX

Default value: 500.0

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

cost_weight_index

Parameter description: Specifies the cost weight of index_scan.

Parameter type: floating-point.

Unit: none

Value range: 1e–10 to 1e+10.

Default value: 1

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

default_limit_rows

Parameter description: Specifies the default estimated number of limit rows for generating genericplan. If this parameter is set to a non-negative value, the value is used as the estimated number of limit rows. If this parameter is set to a negative value, the value is converted to a percentage and used as default estimated value; for example, -5 indicates 5%.

Parameter type: floating-point.

Unit: none

Value range: –100 to DBL_MAX

Default value: –10

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enforce_a_behavior

Parameter description: Specifies the rule matching modes of regular expressions.

Parameter type: Boolean.

Unit: none

Value range:

  • on: The A matching rule is used.
  • off: The POSIX matching rule is used.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

check_implicit_conversions

Parameter description: Specifies whether to check candidate index paths generated for index columns that have implicit type conversion in a query. For details about the application scenarios of this parameter, see "SQL Tuning Guide > Checking the Performance of Implicit Conversion" in Developer Guide.

Parameter type: Boolean.

Unit: none

Value range:

  • on: A check will be performed for candidate index paths generated for index columns that have implicit type conversion in a query.
  • off: No check will be performed.

Default value: off

When this parameter is set to on, you need to set enable_fast_query_shipping to off so that the mechanism for identifying implicit data type conversion of index columns can take effect.

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_opfusion_reuse

Parameter description: Specifies whether to reuse the opfusion obj memory.

Parameter type: Boolean.

Unit: none

Value range:

  • on indicates that the opfusion obj memory is reused when conditions are met.
  • off: This function is disabled.

Default value: on

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none

enable_iud_fusion

Parameter description: Specifies whether to optimize the IUD statements.

Parameter type: Boolean.

Unit: none

Value range:

  • on: The input is optimized during type conversion.
  • off: This function is disabled.

Default value: off

Setting method: This is a USERSET parameter. Set it based on instructions in Table 1.

Setting suggestion: none