diff --git a/clustered-indexes.md b/clustered-indexes.md index d29cbdd7b6b31..31a74827c58fa 100644 --- a/clustered-indexes.md +++ b/clustered-indexes.md @@ -61,7 +61,7 @@ CREATE TABLE t (a BIGINT, b VARCHAR(255), PRIMARY KEY(a, b) /*T![clustered_index CREATE TABLE t (a BIGINT, b VARCHAR(255), PRIMARY KEY(a, b) /*T![clustered_index] NONCLUSTERED */); ``` -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: +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: - `OFF` indicates that primary keys are created as non-clustered indexes by default. - `ON` indicates that primary keys are created as clustered indexes by default. diff --git a/shard-row-id-bits.md b/shard-row-id-bits.md index 9877c6d9e2255..3109bcc48e466 100644 --- a/shard-row-id-bits.md +++ b/shard-row-id-bits.md @@ -9,7 +9,7 @@ This document introduces the `SHARD_ROW_ID_BITS` table attribute, which is used ## Concept -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. +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. 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. @@ -17,7 +17,26 @@ To mitigate the hot spot issue, you can configure `SHARD_ROW_ID_BITS`. The row I - `SHARD_ROW_ID_BITS = 6` indicates 64 shards - `SHARD_ROW_ID_BITS = 0` indicates the default 1 shard + + +For details on the usage, see [the Troubleshoot Hotspot Issues guide](/troubleshoot-hot-spot-issues.md#use-shard_row_id_bits-to-process-hotspots). + + + + + +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). + + + ## Examples -- `CREATE TABLE`: `CREATE TABLE t (c int) SHARD_ROW_ID_BITS = 4;` -- `ALTER TABLE`: `ALTER TABLE t SHARD_ROW_ID_BITS = 4;` +```sql +CREATE TABLE t ( + id INT PRIMARY KEY NONCLUSTERED +) SHARD_ROW_ID_BITS = 4; +``` + +```sql +ALTER TABLE t SHARD_ROW_ID_BITS = 4; +``` diff --git a/troubleshoot-hot-spot-issues.md b/troubleshoot-hot-spot-issues.md index 3f5f4868066e8..9dde874c6bf1d 100644 --- a/troubleshoot-hot-spot-issues.md +++ b/troubleshoot-hot-spot-issues.md @@ -87,9 +87,9 @@ Hover over the bright block, you can see what table or index has a heavy load. F ## Use `SHARD_ROW_ID_BITS` to process hotspots -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. +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. -By setting `SHARD_ROW_ID_BITS`, row IDs are scattered and written into multiple Regions, which can alleviate the write hotspot issue. +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. ``` SHARD_ROW_ID_BITS = 4 # Represents 16 shards.