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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
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
Copy link

@River2000i River2000i Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we keep the original global level?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes,Current implement should add session level sys var change and also keep global level implementation.

- 是否持久化到集群:是
- 是否受 Hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value) 控制:否
- 类型:布尔型
- 默认值:`OFF`
- TiDB 默认会在建表时为新表分裂 Region。开启该变量后,会在建表语句执行时,同步打散刚分裂出的 Region。适用于批量建表后紧接着批量写入数据,能让刚分裂出的 Region 先在 TiKV 分散而不用等待 PD 进行调度。为了保证后续批量写入数据的稳定性,建表语句会等待打散 Region 完成后再返回建表成功,建表语句执行时间会是该变量关闭时的数倍。
- 类型:枚举型
- 默认值:``
- 可选值:``,`TABLE`,`GLOBAL`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hfxsd 后续需要关注下 PR 合并后官方文档的效果,第一个空的可选值导致 GitHub 页面解析有问题:
image

- TiDB 默认会在建表时为新表分裂 Region,使用该变量控制表分裂打散策略,TiDB 会根据选择的打散策略进行 Region 打散。适用于批量建表后紧接着批量写入数据,能让刚分裂出的 Region 先在 TiKV 分散而不用等待 PD 进行调度。为了保证后续批量写入数据的稳定性,建表语句会等待打散 Region 完成后再返回建表成功,建表语句执行时间会是该变量关闭时的数倍。可选值包括:
- 默认值为 ``,表示对于表 Region 不进行打散。
lilin90 marked this conversation as resolved.
Show resolved Hide resolved
- `TABLE` 表示 TiDB 会按照表数据分布情况对于表数据进行打散。
- `GLOBAL` 表示 TiDB 会按照集群整体的数据分布情况对于数据进行打散。在建表语句执行时,同步打散刚分裂出的 Region。
hfxsd 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