Logo
联邦查询

联邦查询 #

语法描述类型
ALTER SQL_FEDERATION RULE修改联邦查询规则RAL
SHOW SQL_FEDERATION RULE查询联邦查询规则RAL

1. 更新联邦查询规则配置 #

alterSQLFederationRule
	: ALTER SQL_FEDERATION RULE sqlFederationRuleDefinition
    ;

sqlFederationRuleDefinition
    : ( sqlFederationEnabled? allQueryUseSQLFederation? (,? executionPlanCache)? (,? advancedParameters)? )
    ;

sqlFederationEnabled
	: SQL_FEDERATION_ENABLED = booleanValue
    ;

allQueryUseSQLFederation
	:	 ALL_QUERY_USE_SQL_FEDERATION = booleanValue
    ;

executionPlanCache
	: EXECUTION_PLAN_CACHE ( cacheOption )
    ;

cacheOption
	: (INITIAL_CAPACITY = initialCapacity)? (,? MAXIMUM_SIZE = maximumSize)?
    ;

initialCapacity
	: intValue
    ;

maximumSize
	: intValue
    ;

advancedParameters
    : maxUsageMemoryPerQuery? (,? spillEnabled)? (,? spillPath)? (,? spillCompressionEnabled)?
    ;

maxUsageMemoryPerQuery
	: MAX_USAGE_MEMORY_PER_QUERY = stringValue
    ;

spillEnabled
	: SPILL_ENABLED = booleanValue
    ;

spillPath
	: SPILL_PATH = stringValue
    ;

spillCompressionEnabled
	: SPILL_COMPRESSION_ENABLED = booleanValue
    ;

参数说明

  • SQL_FEDERATION_ENABLED:联邦查询开关
  • EXECUTION_PLAN_CACHE:执行计划缓存
    • INITIAL_CAPACITY:初始缓存大小
    • MAXIMUM_SIZE:最大缓存大小
  • MAX_USAGE_MEMORY_PER_QUERY: 每个查询最大可用的内存
  • SPILL_ENABLED: 是否启用磁盘交换功能,缺失值为 false
  • SPILL_PATH:磁盘交换文件路径
  • SPILL_COMPRESSION_ENABLED:是否启用压缩以减少磁盘占用,压缩会占用更多 CPU 资源,缺失值为 false

示例

ALTER SQL_FEDERATION RULE (
  SQL_FEDERATION_ENABLED=false,
  EXECUTION_PLAN_CACHE(INITIAL_CAPACITY=2000, MAXIMUM_SIZE=65535),
  MAX_USAGE_MEMORY_PER_QUERY='50M',
  SPILL_ENABLED=false,
  SPILL_PATH="path",
  SPILL_COMPRESSION_ENABLED=false
);

2. 查询联邦查询规则配置 #

SHOW SQL_FEDERATION RULE

输出说明

说明
sql_federation_enabled联邦查询开关
all_query_use_sql_federation是否所有查询通过联邦查询执行
execution_plan_cache执行计划缓存配置
max_usage_memory_per_query每个查询最大可用的内存
spill_enabled是否启用磁盘交换功能
spill_path磁盘交换文件路径
spill_compression_enabled是否启用磁盘交换文件压缩

示例

mysql> SHOW SQL_FEDERATION RULE;
+------------------------+------------------------------+-------------------------------------------+----------------------------+---------------+------------+---------------------------+
| sql_federation_enabled | all_query_use_sql_federation | execution_plan_cache                      | max_usage_memory_per_query | spill_enabled | spill_path | spill_compression_enabled |
+------------------------+------------------------------+-------------------------------------------+----------------------------+---------------+------------+---------------------------+
| false                  | false                        | initialCapacity: 2000, maximumSize: 65535 | 50M                        | false         | path       | false                     |
+------------------------+------------------------------+-------------------------------------------+----------------------------+---------------+------------+---------------------------+
1 row in set (0.01 sec)