Skip to content

Commit ef548db

Browse files
authored
Update docs of SHARD_ROW_ID_BITS (#12891) (#12923) (#12925)
1 parent e5d1374 commit ef548db

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

clustered-indexes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ CREATE TABLE t (a BIGINT, b VARCHAR(255), PRIMARY KEY(a, b) /*T![clustered_index
6161
CREATE TABLE t (a BIGINT, b VARCHAR(255), PRIMARY KEY(a, b) /*T![clustered_index] NONCLUSTERED */);
6262
```
6363

64-
For statements that do not explicitly specify the keyword `CLUSTERED`/`NONCLUSTERED`, the default behavior is controlled by the system variable `@@global.tidb_enable_clustered_index`. Supported values for this variable are as follows:
64+
For statements that do not explicitly specify the keyword `CLUSTERED`/`NONCLUSTERED`, the default behavior is controlled by the system variable [`@@global.tidb_enable_clustered_index`](/system-variables.md#tidb_enable_clustered_index-new-in-v50). Supported values for this variable are as follows:
6565

6666
- `OFF` indicates that primary keys are created as non-clustered indexes by default.
6767
- `ON` indicates that primary keys are created as clustered indexes by default.

shard-row-id-bits.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,34 @@ This document introduces the `SHARD_ROW_ID_BITS` table attribute, which is used
99

1010
## Concept
1111

12-
For the tables with a non-integer primary key or no primary key, TiDB uses an implicit auto-increment row ID. When a large number of `INSERT` operations are performed, the data is written into a single Region, causing a write hot spot.
12+
For the tables with a non-clustered primary key or no primary key, TiDB uses an implicit auto-increment row ID. When a large number of `INSERT` operations are performed, the data is written into a single Region, causing a write hot spot.
1313

1414
To mitigate the hot spot issue, you can configure `SHARD_ROW_ID_BITS`. The row IDs are scattered and the data are written into multiple different Regions.
1515

1616
- `SHARD_ROW_ID_BITS = 4` indicates 16 shards
1717
- `SHARD_ROW_ID_BITS = 6` indicates 64 shards
1818
- `SHARD_ROW_ID_BITS = 0` indicates the default 1 shard
1919

20+
<CustomContent platform="tidb">
21+
22+
For details on the usage, see [the Troubleshoot Hotspot Issues guide](/troubleshoot-hot-spot-issues.md#use-shard_row_id_bits-to-process-hotspots).
23+
24+
</CustomContent>
25+
26+
<CustomContent platform="tidb-cloud">
27+
28+
For details on the usage, see [the Troubleshoot Hotspot Issues guide](https://docs.pingcap.com/tidb/stable/troubleshoot-hot-spot-issues#use-shard_row_id_bits-to-process-hotspots).
29+
30+
</CustomContent>
31+
2032
## Examples
2133

22-
- `CREATE TABLE`: `CREATE TABLE t (c int) SHARD_ROW_ID_BITS = 4;`
23-
- `ALTER TABLE`: `ALTER TABLE t SHARD_ROW_ID_BITS = 4;`
34+
```sql
35+
CREATE TABLE t (
36+
id INT PRIMARY KEY NONCLUSTERED
37+
) SHARD_ROW_ID_BITS = 4;
38+
```
39+
40+
```sql
41+
ALTER TABLE t SHARD_ROW_ID_BITS = 4;
42+
```

troubleshoot-hot-spot-issues.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ Hover over the bright block, you can see what table or index has a heavy load. F
8787
8888
## Use `SHARD_ROW_ID_BITS` to process hotspots
8989
90-
For a non-integer primary key or a table without a primary key or a joint primary key, TiDB uses an implicit auto-increment RowID. When a large number of `INSERT` operations exist, the data is written into a single Region, resulting in a write hotspot.
90+
For a non-clustered primary key or a table without a primary key, TiDB uses an implicit auto-increment RowID. When a large number of `INSERT` operations exist, the data is written into a single Region, resulting in a write hotspot.
9191
92-
By setting `SHARD_ROW_ID_BITS`, row IDs are scattered and written into multiple Regions, which can alleviate the write hotspot issue.
92+
By setting [`SHARD_ROW_ID_BITS`](/shard-row-id-bits.md), row IDs are scattered and written into multiple Regions, which can alleviate the write hotspot issue.
9393
9494
```
9595
SHARD_ROW_ID_BITS = 4 # Represents 16 shards.

0 commit comments

Comments
 (0)