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 #18901

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions system-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -5151,12 +5151,16 @@ SHOW WARNINGS;
>
> This variable is read-only for [TiDB Cloud Serverless](https://docs.pingcap.com/tidbcloud/select-cluster-tier#tidb-cloud-serverless).

- Scope: GLOBAL
- Scope: SESSION | GLOBAL
- Persists to cluster: Yes
- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No
- Type: Boolean
- Default value: `OFF`
- By default, Regions are split for a new table when it is being created in TiDB. After this variable is enabled, the newly split Regions are scattered immediately during the execution of the `CREATE TABLE` statement. This applies to the scenario where data need to be written in batches right after the tables are created in batches, because the newly split Regions can be scattered in TiKV beforehand and do not have to wait to be scheduled by PD. To ensure the continuous stability of writing data in batches, the `CREATE TABLE` statement returns success only after the Regions are successfully scattered. This makes the statement's execution time multiple times longer than that when you disable this variable.
- Type: Enumeration
- Default value: `""`
- Possible values: `""`, `TABLE`, `GLOBAL`
- By default, Regions are split for a new table when it is being created in TiDB. This variable controls the table Region scattering strategy, determining how TiDB scatters Regions after splitting. This applies to the scenario where data need to be written in batches right after the tables are created in batches, because the newly split Regions can be scattered in TiKV beforehand and do not have to wait to be scheduled by PD. To ensure the continuous stability of writing data in batches, the `CREATE TABLE` statement returns success only after the Regions are successfully scattered. This makes the statement's execution time multiple times longer than that when you disable this variable. Possible values are:
lilin90 marked this conversation as resolved.
Show resolved Hide resolved
- `""`: indicates TiDB does not scatter table Regions.
lilin90 marked this conversation as resolved.
Show resolved Hide resolved
- `TABLE`: indicates that if you set `PRE_SPLIT_REGIONS` or `SHARD_ROW_ID_BITS` when you create a table, in the scenario of pre-splitting multiple Regions, the Regions of these tables will be scattered according to the granularity of the tables. However, if you don't set the aforementioned attributes when you create a table, in the scenario of creating a large number of tables quickly, it will cause the Regions of these tables to be concentrated on a few TiKV nodes, resulting in an uneven distribution of the Regions.
lilin90 marked this conversation as resolved.
Show resolved Hide resolved
- `GLOBAL`: indicates that TiDB scatters the Regions of newly created tables according to the data distribution of the entire cluster. Particularly when you create a large number of tables quickly, using the `GLOBAL` option, you can effectively avoid over-concentration of Regions on a few TiKV nodes, and ensure an even distribution of Regions.
lilin90 marked this conversation as resolved.
Show resolved Hide resolved
- Note that if `SHARD_ROW_ID_BITS` and `PRE_SPLIT_REGIONS` have been set when a table is created, the specified number of Regions are evenly split after the table creation.

### tidb_schema_cache_size <span class="version-mark">New in v8.0.0</span>
Expand Down
Loading