Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys-var: change tidb_scatter_region usage definition #18626

Merged
merged 14 commits into from
Oct 15, 2024
12 changes: 8 additions & 4 deletions system-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -4149,12 +4149,16 @@ EXPLAIN FORMAT='brief' SELECT COUNT(1) FROM t WHERE a = 1 AND b IS NOT NULL;

### `tidb_scatter_region`

- 作用域:GLOBAL
- 作用域:SESSION | GLOBAL
lilin90 marked this conversation as resolved.
Show resolved Hide resolved
- 是否持久化到集群:是
- 是否受 Hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value) 控制:否
- 类型:布尔型
- 默认值:`OFF`
- TiDB 默认会在建表时为新表分裂 Region。开启该变量后,会在建表语句执行时,同步打散刚分裂出的 Region。适用于批量建表后紧接着批量写入数据,能让刚分裂出的 Region 先在 TiKV 分散而不用等待 PD 进行调度。为了保证后续批量写入数据的稳定性,建表语句会等待打散 Region 完成后再返回建表成功,建表语句执行时间会是该变量关闭时的数倍。
- 类型:枚举型
- 默认值:``
- 可选值:``,`TABLE`,`GLOBAL`
lilin90 marked this conversation as resolved.
Show resolved Hide resolved
hfxsd marked this conversation as resolved.
Show resolved Hide resolved
- TiDB 默认会在建表时为新表分裂 Region,使用该变量控制表分裂打散策略,TiDB 会根据选择的打散策略进行 Region 打散。适用于批量建表后紧接着批量写入数据,能让刚分裂出的 Region 先在 TiKV 分散而不用等待 PD 进行调度。为了保证后续批量写入数据的稳定性,建表语句会等待打散 Region 完成后再返回建表成功,建表语句执行时间会是该变量关闭时的数倍。可选值包括:
lilin90 marked this conversation as resolved.
Show resolved Hide resolved
- 默认值为 ``,表示对于表 Region 不进行打散。
lilin90 marked this conversation as resolved.
Show resolved Hide resolved
- `TABLE`:表示当你建表时,如果设置了 `PRE_SPLIT_REGIONS` 或者 `SHARD_ROW_ID_BITS`,预分裂多个 Region 的场景下,会按表的粒度对这些表的 Region 进行打散。但是如果你这建表时没有设置上述属性,在快速创建大量表的场景,会导致这些表的 Region 集中在其中几个 TiKV 节点上,造成 Region 分布不均匀。
jebter marked this conversation as resolved.
Show resolved Hide resolved
hfxsd marked this conversation as resolved.
Show resolved Hide resolved
- `GLOBAL`:表示 TiDB 会根据整个集群的数据分布情况来打散新建表的 Region。特别是快速创建大量表的时候,使用 `GLOBAL` 可以有效避免 Region 过度集中在少数几个 TiKV 节点上,确保 Region 分布均匀。
lilin90 marked this conversation as resolved.
Show resolved Hide resolved
- 如果建表时设置了 `SHARD_ROW_ID_BITS` 和 `PRE_SPLIT_REGIONS`,建表成功后会均匀切分出指定数量的 Region。

### `tidb_schema_version_cache_limit` <span class="version-mark">从 v7.4.0 版本开始引入</span>
Expand Down