-
Notifications
You must be signed in to change notification settings - Fork 709
pd,tidb: support affinity schedule #22270
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6f8edf2
Add temp.md
qiancai b995510
Delete temp.md
qiancai d8d49a7
Auto-sync: Update English docs from Chinese PR
github-actions[bot] c1b3a42
revise translation
qiancai 47b7bd0
minor wording updates
qiancai 640e63f
Apply suggestions from code review
qiancai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| --- | ||
| title: SHOW AFFINITY | ||
| summary: An overview of the usage of SHOW AFFINITY for the TiDB database. | ||
| --- | ||
|
|
||
| # SHOW AFFINITY <span class="version-mark">New in v8.5.5 and v9.0.0</span> | ||
|
|
||
| The `SHOW AFFINITY` statement shows [affinity](/table-affinity.md) scheduling information for tables configured with the `AFFINITY` option, as well as the target replica distribution currently recorded by PD. | ||
|
|
||
| ## Synopsis | ||
|
|
||
| ```ebnf+diagram | ||
| ShowAffinityStmt ::= | ||
| "SHOW" "AFFINITY" ShowLikeOrWhereOpt | ||
| ``` | ||
|
|
||
| `SHOW AFFINITY` supports filtering table names using `LIKE` or `WHERE` clauses. | ||
|
|
||
| ## Examples | ||
|
|
||
| The following examples create two tables with affinity scheduling enabled and show how to view their scheduling information: | ||
|
|
||
| ```sql | ||
| CREATE TABLE t1 (a INT) AFFINITY = 'table'; | ||
| CREATE TABLE tp1 (a INT) AFFINITY = 'partition' PARTITION BY HASH(a) PARTITIONS 2; | ||
|
|
||
| SHOW AFFINITY; | ||
| ``` | ||
|
|
||
| The example output is as follows: | ||
|
|
||
| ```sql | ||
| +---------+------------+----------------+-----------------+------------------+----------+--------------+----------------------+ | ||
| | Db_name | Table_name | Partition_name | Leader_store_id | Voter_store_ids | Status | Region_count | Affinity_region_count| | ||
| +---------+------------+----------------+-----------------+------------------+----------+--------------+----------------------+ | ||
| | test | t1 | NULL | 1 | 1,2,3 | Stable | 8 | 8 | | ||
| | test | tp1 | p0 | 4 | 4,5,6 | Preparing| 4 | 2 | | ||
| | test | tp1 | p1 | 4 | 4,5,6 | Preparing| 3 | 2 | | ||
| +---------+------------+----------------+-----------------+------------------+----------+--------------+----------------------+ | ||
| ``` | ||
|
|
||
| The meaning of each column is as follows: | ||
|
|
||
| - `Leader_store_id`, `Voter_store_ids`: the IDs of TiKV stores recorded by PD, indicating which stores host the target Leader and Voter replicas for the table or partitions. If the target replica locations for the affinity group are not determined, or if [`schedule.affinity-schedule-limit`](/pd-configuration-file.md#affinity-schedule-limit-new-in-v855-and-v900) is set to `0`, the value is displayed as `NULL`. | ||
| - `Status`: indicates the current status of affinity scheduling. Possible values are: | ||
| - `Pending`: PD has not started affinity scheduling for the table or partition, such as when Leaders or Voters are not yet determined. | ||
| - `Preparing`: PD is scheduling Regions to meet affinity requirements. | ||
| - `Stable`: all Regions have reached the target distribution. | ||
| - `Region_count`: the current number of Regions in the affinity group. | ||
| - `Affinity_region_count`: the number of Regions that currently meet the affinity replica distribution requirements. | ||
| - When `Affinity_region_count` is less than `Region_count`, it indicates that some Regions have not yet completed replica scheduling based on affinity. | ||
| - When `Affinity_region_count` equals `Region_count`, it indicates that replica scheduling based on affinity is complete, meaning the distribution of all related Regions meets the affinity requirements. However, this does not indicate that related Region merge operations are complete. | ||
|
|
||
| ## MySQL compatibility | ||
|
|
||
| This statement is a TiDB extension to MySQL syntax. | ||
|
|
||
| ## See also | ||
|
|
||
| - [`CREATE TABLE`](/sql-statements/sql-statement-create-table.md) | ||
| - [`ALTER TABLE`](/sql-statements/sql-statement-alter-table.md) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR does not add this doc to the cloud TOC because this feature will be provided on cloud after it is enabled by default in a future version