更新时间:2025-10-11 GMT+08:00

配置参数的hint

功能描述

指明计划生成时配置参数的值,又称作guc hint。

注意事项

  • 如果hint设置的配置参数在语句级别生效,则该hint必须写在顶层查询中,而不能写在子查询中。对于UNION、INTERSECT、EXCEPT和MINUS语句,可以将在语句级别的guc hint写在参与集合运算的任意一个SELECT子句上,该guc hint设置的配置参数会在参与集合运算的每个SELECT子句上生效。
  • 子查询提升时,该子查询上的所有guc hint会被丢弃。
  • 如果一个配置参数既被语句级别的guc hint设置,又被子查询级别的guc hint设置,则子查询级别的guc hint在对应的子查询中生效,语句级别的guc hint在语句的其它子查询中生效。

语法格式

set [global]([@block_name] guc_name guc_value)

参数说明

  • global表示hint设置的配置参数在语句级别生效,不加global表示hint设置的配置参数在子查询级别生效,即仅在hint所在的子查询中生效,在该语句的其它子查询中不生效。
  • block_name表示语句块的block_name,详细说明请参考block_name。
  • guc_name表示hint指定的配置参数的名称。
  • guc_value表示hint指定的配置参数的值。

guc hint当前仅支持部分配置参数,并且有些配置参数不支持在子查询级别设置,只能在语句级别设置,以下为支持的参数列表:

表1 guc hint支持的配置参数

配置参数名

是否支持在子查询级别设置

agg_max_mem

是

agg_redistribute_enhancement

是

best_agg_plan

是

cost_model_version

否

cost_param

否

enable_array_optimization

否

enable_bitmapscan

是

enable_broadcast

是

enable_csqual_pushdown

否

enable_redistribute

是

enable_extrapolation_stats

是

enable_fast_query_shipping

否

enable_force_vector_engine

否

enable_hashagg

是

enable_hashfilter

否

enable_hashjoin

是

enable_index_nestloop

是

enable_indexonlyscan

是

enable_indexscan

是

enable_join_pseudoconst

是

enable_mergejoin

是

enable_mixedagg

否

enable_nestloop

是

enable_nodegroup_debug

否

enable_partition_dynamic_pruning

是

enable_seqscan

是

enable_sonic_hashagg

否

enable_sonic_hashjoin

是

enable_sort

是

enable_stream_ctescan

否

enable_tidscan

是

enable_value_redistribute

是

enable_vector_engine

否

expected_computing_nodegroup

否

force_bitmapand

是

from_collapse_limit

是

join_collapse_limit

是

join_num_distinct

是

outer_join_max_rows_multipler

是

prefer_hashjoin_path

否

qrw_inlist2join_optmode

是

qual_num_distinct

是

query_dop

否

query_max_mem

否

query_mem

否

rewrite_rule

否

setop_optmode

是

skew_option

是

stream_ctescan_max_estimate_mem

否

stream_ctescan_pred_threshold

否

stream_ctescan_refcount_threshold

否

windowagg_pushdown_enhancement

否

index_selectivity_cost

是

index_cost_limit

是

示例

对示例中原语句使用如下hint:

explain
select /*+ set global(query_dop 0) */ i_product_name product_name
...

该hint表示:在整个语句的计划生成过程中,将配置参数query_dop设置为0,即打开SMP自适应功能。生成的计划如下图所示: