Updated on 2026-11-09 GMT+08:00

Other Optimizer Options

The quality of a query plan directly affects the SQL execution performance. Settings such as statistics sampling, planning constraints, degree of parallelism, and inter-node communication mode affect the selection of query plans. This section describes other optimizer options, including the statistics sampling target (default_statistics_target), planning collapse limits (from_collapse_limit and join_collapse_limit), SMP and actor parallelism (query_dop and fq_query_vdn), and inter-node communication mode (enable_libcomm). You can adjust these parameters based on the data scale and service load to improve the accuracy and execution efficiency of query plans.

Parameter Description

Table 1 Other optimizer options

Parameter

Type

Description

default_statistics_target

Float

Definition: Specifies the default statistics target for tables that have not had a statistics target set for any column with ALTER TABLE SET STATISTICS. If this parameter is set to a positive number, it indicates the number of samples for statistics. If this parameter is set to a negative number, it indicates that the statistics target is set in percentage. The negative number is converted to the corresponding percentage. For example, -5 indicates 5%. During sampling, the value of default_statistics_target multiplied by 300 is used as the size of random sampling. For example, if the default value is 100, 30,000 pages are randomly read and 30,000 data records are randomly selected from the pages to complete random sampling.

Range: A floating point number ranging from –100 to 10,000.

NOTE:
  • A larger positive number than the default value increases the time required to do ANALYZE, but might improve the quality of the optimizer's estimates.
  • Adjusting this parameter may cause performance deterioration. If a query is degraded, you can restore the default statistics or use plan hints to adjust the query plan to the previous one.
  • When this GUC parameter is set to a negative value, if the computed sample size is greater than or equal to 2% of the total data volume and the table contains fewer than 1,600,000 rows, the ANALYZE duration may exceed that of the default GUC parameter setting.
  • AUTOANALYZE does not support customizing the sampling size for temporary tables. The default value is used instead.
  • If statistics are forcibly calculated in-memory, the sampling size is constrained by the maintenance_work_mem parameter.

Default Value: 100.

from_collapse_limit

Integer

Definition: Specifies whether the optimizer merges subqueries into upper-level queries based on the number of items in the generated FROM list. If the number of items in the FROM list is less than or equal to this value, the optimizer merges subqueries into upper-level queries.

Range: An integer, in the range [1, INT_MAX].

NOTE:

Smaller values reduce planning time but may lead to inferior execution plans.

Default Value: 8.

join_collapse_limit

Integer

Definition: Specifies whether the optimizer rewrites the JOIN constructs except FULL JOINS into the FROM list based on the number of items in the list.

Range: An integer, in the range [1, INT_MAX].

NOTE:
  • Setting this parameter to 1 prevents any JOIN reordering. In this way, the join order specified in the query is the actual join order. The query optimizer does not always select the optimal join order. Advanced users can temporarily set this variable to 1 and then specify the required join order.
  • Smaller values reduce planning time but degrade the quality of execution plans.

Default Value: 8.

enable_libcomm

Boolean

Definition: Specifies whether DNs communicate with each other through libcomm.

Range: Boolean.

  • on: libcomm is used for communication between DNs.
  • off: The stream is used for communication between DNs.

Default Value: off.

enable_bloom_filter

Boolean

Definition: Specifies whether BloomFilter optimization is allowed.

This function is applicable to scenarios where a HASH JOIN on the foreign table side, which includes HDFS internal/foreign tables or column-store tables in the same thread, triggers the Bloom Filter optimization.

Constraints:

  1. The JOIN type can only be INNER JOIN, SEMI JOIN, RIGHT JOIN, RIGHT SEMI JOIN, RIGHT ANTI JOIN, or RIGHT ANTI FULL JOIN.
  2. Join condition on the inner table side of JOIN: The join condition cannot be an expression for HDFS internal and foreign tables. The join condition can be an expression for column-store tables, but only for non-JOIN layer calculation.
  3. The association condition of the JOIN foreign table must be simple column association.
  4. If the association conditions of both the internal and external tables of JOIN are simple column association, more than 1/3 of the data can be removed from the estimation at the plan layer (only for HDFS internal and external tables).
  5. The JOIN cannot contain null value associations.
  6. Data types:
    • The HDFS internal and external table field types support SMALLINT, INTEGER, BIGINT, REAL/FLOAT4, DOUBLE PRECISION/FLOAT8, CHAR(n)/CHARACTER(n)/NCHAR(n), VARCHAR(n)/CHARACTER VARYING(n), CLOB, and TEXT.
    • The column-store table supports the SMALLINT, INTEGER, BIGINT, OID, "char", CHAR(n)/CHARACTER(n)/NCHAR(n), VARCHAR(n)/CHARACTER VARYING(n), NVARCHAR2(n), CLOB, TEXT, DATE, TIME, TIMESTAMP, and TIMESTAMPTZ field types. The collation of the character type must be C.

Range: Boolean.

  • on: The BloomFilter optimization can be used.
  • off: The BloomFilter optimization cannot be used.

Default Value: None.

enable_extrapolation_stats

Boolean

Definition: Specifies whether to allow the use of inference-based estimation logic based on historical statistics. Using this logic can increase the possibility of accurate estimation for tables whose statistics are not collected in time. However, there is also a possibility that the estimation is too large due to incorrect inference.

Range: Boolean.

  • on: The inference-based estimation logic is allowed to be used based on historical statistics.
  • off: The inference-based estimation logic is not allowed to be used based on historical statistics.

Default Value: off.

query_dop

Integer

Definition: Specifies the user-defined query parallelism.

Range: An integer, in the range [–64, 64].

  • [–64, –1]: SMP adaptation is enabled, and the maximum degree of parallelism that can be dynamically selected is limited.
  • 0: SMP adaptation is enabled. The system dynamically selects the optimal degree of parallelism for each query based on resource conditions and plan characteristics, within the range of [1, 8] on x86 platforms and [1, 64] on Kunpeng platforms.
  • [1, 64]: Fixed SMP is enabled, and the system will use the specified degree of parallelism.

Default Value: 1.

smp_thread_cost

Float

Definition: Specifies the minimum estimated cost that each SMP thread should carry when planning the degree of parallelism in the SMP adaptive scenario. If the estimated cost of an operator is low but the degree of parallelism is high, causing the estimated cost calculated by each SMP thread to be less than this threshold, the optimizer automatically reduces the degree of parallelism of the operator. This prevents system resources from being wasted by enabling a high degree of parallelism for low-cost operators.

Range: A floating point number, in the range [0, 10000].

  • 0: The estimated cost threshold of the SMP thread is disabled. In this case, the DOP is not affected by the operator cost.
  • (0, 10000]: Minimum estimated cost threshold of SMP threads. A larger value indicates that the DOP of low-cost operators tends to decrease.
NOTE:

If this parameter is not set to 0 and the estimated cost of an operator is too small, the degree of parallelism in SMP is low. In this case, you can set this parameter to 0 to increase the degree of parallelism.

Default Value: 1000.

plan_mode_seed

Integer

Definition: This parameter is a debug parameter. It controls whether the optimizer uses the dynamic programming algorithm to estimate the optimal execution plan or generates a random plan. Parameter type: USERSET.

Range: An integer, in the range [–1, 2147483647].

  • 0: Optimal execution plan whose cost is estimated using the dynamic planning algorithm.
  • –1: The optimizer randomly generates a random integer ranging from 1 to 2147483647 and generates a random execution plan based on the random number.
  • [1, 2147483647]: The optimizer generates a random execution plan based on the specified random number.
NOTE:
  • When this parameter is set to the random plan mode, the optimizer generates different random execution plans, which may not be the optimal plan. Therefore, the random plan mode affects the query performance. You are advised to set this parameter to the default value 0 during normal service operations or O&M.
  • If this parameter is not set to 0, the specified plan hint does not take effect.

Default Value: 0.

fq_query_vdn

Integer

Definition: Specifies the number of actors that can be started for a task.

Range: An integer, in the range [0, 256].

  • 0: The number of actors is adaptively determined. The number of actors is dynamically selected based on the scanning and write costs.
  • 1: A single actor is used, and the execution mode is degraded to the single CN mode.
  • 2–256: Use a specified number of actors for execution.

Default Value: 2.

fq_actor_adapt_type

Enum

Definition: Specifies the mode in which actors are started adaptively.

Range: Enumerated values.

  • default: The adaptive mode is not used. The default specifications of the actor are 4 vCPUs and 16 GB memory.
  • mem: The actor specifications are automatically adapted. The ratio of CPU to memory is 1:4, and the CPU range is [1, 16].
NOTE:

This parameter only takes effect when actor count adaptation is enabled (that is, fq_query_vdn = 0).

Default Value: mem.

fq_dynamic_actor_cost_threshold

Float

Definition: Specifies the threshold of the single-CN cost when fq_query_vdn is set to 0. If the threshold is exceeded, the actor is started.

Range: A floating point number, in the range [1, 1e10].

Default Value: 200000.

NOTE:

During adaptation, the number of selected actors and the cost are not in a simple linear relationship. Instead, they are in a process of gradient descent. As the cost increases, the number of selected actors tends to 256.

objref_transfer_options

String

Definition: Specifies the settings related to big data transfer. The parameter value is a string of comma-separated key-value pairs, with each pair in the format of (key:value). This parameter takes effect only when objectref_transfer is set in sql_opt_options.

Range: A string of key-value pairs.

  • release_batch_threshold: The value is an integer in the range [1, INT_MAX]. The default value is 16. This parameter controls the number of batches that the consumer accumulates before notifying the producer to release ObjectRef.
  • width_threshold: The value is an integer in the range [0, INT_MAX] (the unit cannot be added to the value, and the unit is byte). The default value is 0. This parameter controls the number of bytes that the estimated column width exceeds. The default value is 0, indicating that this parameter does not take effect. The bytea column is not controlled by the second parameter.
  • row_serialize: The value is of Boolean type. The default value is off. This parameter controls whether to accumulate batches and send them in serialized mode for streams except broadcast and roundrobin that is sent by batch. off/false indicates that streams are serialized and sent in batches. on/true indicates that streams are serialized and sent row by row.

Default Value: (release_batch_threshold:16),(width_threshold:0).

Example:

set objref_transfer_options = "(release_batch_threshold:16),(width_threshold:0)";