联邦查询 #
语法 | 描述 | 类型 |
---|---|---|
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
: 是否启用磁盘交换功能,缺失值为 falseSPILL_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)