Skip to content

Commit 073765f

Browse files
ti-chi-botqiancaiqiancai
authored
cloud: add SQL and TiFlash related docs (pingcap#9001) (pingcap#9479) (pingcap#9859)
* correct-the-title-level Updated the title level of "Concentrated reads or writes" from the 2nd to the 3rd. * Revert "correct-the-title-level" This reverts commit c879598. * TiUP: Fix broken links and errors * Revert "TiUP: Fix broken links and errors" This reverts commit b0db8e6. * Update dm-release-notes.md * Revert "Update dm-release-notes.md" This reverts commit 1744d50. * This is an automated cherry-pick of pingcap#9479 Signed-off-by: ti-chi-bot <[email protected]> * This is an automated cherry-pick of pingcap#9479 Signed-off-by: ti-chi-bot <[email protected]> * Update TOC-tidb-cloud.md * update_cloud_docs_to_latest * Update TOC-tidb-cloud.md * Update TOC-tidb-cloud.md * update_links * Update TOC-tidb-cloud.md * Update TOC-tidb-cloud.md * add_custom_content * update_links_temporarily * fix lint errors Signed-off-by: ti-chi-bot <[email protected]> Co-authored-by: qiancai <“[email protected]”> Co-authored-by: qiancai <[email protected]>
1 parent 9d34df4 commit 073765f

File tree

94 files changed

+2564
-456
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2564
-456
lines changed

TOC-tidb-cloud.md

+357
Large diffs are not rendered by default.

agg-distinct-optimization.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,19 @@ mysql> explain SELECT DISTINCT a from t;
2727

2828
Usually, aggregate functions with the `DISTINCT` option is executed in the TiDB layer in a single-threaded execution model.
2929

30-
The [`tidb_opt_distinct_agg_push_down`](/system-variables.md#tidb_opt_distinct_agg_push_down) system variable or the [`distinct-agg-push-down`](/tidb-configuration-file.md#distinct-agg-push-down) configuration item in TiDB controls whether to rewrite the distinct aggregate queries and push them to the TiKV/TiFlash Coprocessor.
30+
<CustomContent platform="tidb">
3131

32-
Take the following queries as an example of this optimization. `tidb_opt_distinct_agg_push_down` is disabled by default, which means the aggregate functions are executed in the TiDB layer. After enabling this optimization by setting its value to `1`, the `distinct a` part of `count(distinct a)` is pushed to TiKV/TiFlash Coprocessor: there is a HashAgg_5 to remove the duplicated values on column a in the TiKV Coprocessor. It might reduce the computation overhead of `HashAgg_8` in the TiDB layer.
32+
The [`tidb_opt_distinct_agg_push_down`](/system-variables.md#tidb_opt_distinct_agg_push_down) system variable or the [`distinct-agg-push-down`](/tidb-configuration-file.md#distinct-agg-push-down) configuration item in TiDB controls whether to rewrite the distinct aggregate queries and push them to the TiKV or TiFlash Coprocessor.
33+
34+
</CustomContent>
35+
36+
<CustomContent platform="tidb-cloud">
37+
38+
The [`tidb_opt_distinct_agg_push_down`](/system-variables.md#tidb_opt_distinct_agg_push_down) system variable in TiDB controls whether to rewrite the distinct aggregate queries and push them to the TiKV or TiFlash Coprocessor.
39+
40+
</CustomContent>
41+
42+
Take the following queries as an example of this optimization. `tidb_opt_distinct_agg_push_down` is disabled by default, which means the aggregate functions are executed in the TiDB layer. After enabling this optimization by setting its value to `1`, the `distinct a` part of `count(distinct a)` is pushed to TiKV or TiFlash Coprocessor: there is a HashAgg_5 to remove the duplicated values on column a in the TiKV Coprocessor. It might reduce the computation overhead of `HashAgg_8` in the TiDB layer.
3343

3444
```sql
3545
mysql> desc select count(distinct a) from test.t;

auto-increment.md

+12
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,22 @@ aliases: ['/docs/dev/auto-increment/']
88

99
This document introduces the `AUTO_INCREMENT` column attribute, including its concept, implementation principles, auto-increment related features, and restrictions.
1010

11+
<CustomContent platform="tidb">
12+
1113
> **Note:**
1214
>
1315
> The `AUTO_INCREMENT` attribute might cause hotspot in production environments. See [Troubleshoot HotSpot Issues](/troubleshoot-hot-spot-issues.md) for details. It is recommended to use [`AUTO_RANDOM`](/auto-random.md) instead.
1416
17+
</CustomContent>
18+
19+
<CustomContent platform="tidb-cloud">
20+
21+
> **Note:**
22+
>
23+
> The `AUTO_INCREMENT` attribute might cause hotspot in production environments. See [Troubleshoot HotSpot Issues](https://docs.pingcap.com/tidb/stable/troubleshoot-hot-spot-issues#handle-auto-increment-primary-key-hotspot-tables-using-auto_random) for details. It is recommended to use [`AUTO_RANDOM`](/auto-random.md) instead.
24+
25+
</CustomContent>
26+
1527
## Concept
1628

1729
`AUTO_INCREMENT` is a column attribute that is used to automatically fill in default column values. When the `INSERT` statement does not specify values for the `AUTO_INCREMENT` column, the system automatically assigns values to this column.

auto-random.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ aliases: ['/docs/dev/auto-random/','/docs/dev/reference/sql/attributes/auto-rand
88

99
> **Note:**
1010
>
11-
> `AUTO_RANDOM` was marked as stable in v4.0.3.
11+
> `AUTO_RANDOM` has been generally available since v4.0.3.
1212
1313
## User scenario
1414

15-
When you write data intensively into TiDB and TiDB has the table with a primary key of the auto-increment integer type, hotspot issue might occur. To solve the hotspot issue, you can use the `AUTO_RANDOM` attribute. Refer to [Highly Concurrent Write Best Practices](/best-practices/high-concurrency-best-practices.md#complex-hotspot-problems) for details.
15+
When you write data intensively into TiDB and TiDB has a table with the primary key of the auto-increment integer type, hotspot issue might occur. To solve the hotspot issue, you can use the `AUTO_RANDOM` attribute.
16+
17+
<CustomContent platform="tidb">
18+
19+
For more information, see [Highly Concurrent Write Best Practices](/best-practices/high-concurrency-best-practices.md#complex-hotspot-problems).
20+
21+
</CustomContent>
1622

1723
Take the following created table as an example:
1824

basic-sql-operations.md

-10
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,8 @@ aliases: ['/docs/dev/basic-sql-operations/','/docs/dev/how-to/get-started/explor
66

77
# Explore SQL with TiDB
88

9-
<CustomContent platform="tidb">
10-
119
TiDB is compatible with MySQL, you can use MySQL statements directly in most of the cases. For unsupported features, see [Compatibility with MySQL](/mysql-compatibility.md#unsupported-features).
1210

13-
</CustomContent>
14-
15-
<CustomContent platform="tidb-cloud">
16-
17-
TiDB is compatible with MySQL, you can use MySQL statements directly in most of the cases. For unsupported features, see [Compatibility with MySQL](https://docs.pingcap.com/tidb/stable/mysql-compatibility#unsupported-features).
18-
19-
</CustomContent>
20-
2111
<CustomContent platform="tidb">
2212

2313
To experiment with SQL and test out TiDB compatibility with MySQL queries, you can [run TiDB directly in your web browser without installing it](https://tour.tidb.io/). You can also first deploy a TiDB cluster and then run SQL statements in it.

certificate-authentication.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@ The rest of the document introduces in detail how to perform these operations.
1919

2020
## Create security keys and certificates
2121

22-
It is recommended that you use [OpenSSL](https://www.openssl.org/) to create keys and certificates. The certificate generation process is similar to the process described in [Enable TLS Between TiDB Clients and Servers](/enable-tls-between-clients-and-servers.md). The following paragraphs demonstrate on how to configure more attribute fields that need to be verified in the certificate.
22+
<CustomContent platform="tidb">
23+
24+
It is recommended that you use [OpenSSL](https://www.openssl.org/) to create keys and certificates. The certificate generation process is similar to the process described in [Enable TLS Between TiDB Clients and Servers](/enable-tls-between-clients-and-servers.md). The following paragraphs demonstrate how to configure more attribute fields that need to be verified in the certificate.
25+
26+
</CustomContent>
27+
28+
<CustomContent platform="tidb-cloud">
29+
30+
It is recommended that you use [OpenSSL](https://www.openssl.org/) to create keys and certificates. The certificate generation process is similar to the process described in [Enable TLS Between TiDB Clients and Servers](https://docs.pingcap.com/tidb/stable/enable-tls-between-clients-and-servers). The following paragraphs demonstrate how to configure more attribute fields that need to be verified in the certificate.
31+
32+
</CustomContent>
2333

2434
### Generate CA key and certificate
2535

@@ -278,7 +288,7 @@ The user certificate information can be specified by `require subject`, `require
278288
openssl x509 -noout -subject -in ca-cert.pem | sed 's/.\{8\}//' | sed 's/, /\//g' | sed 's/ = /=/g' | sed 's/^/\//'
279289
```
280290

281-
+ `require san`: Specifies the `Subject Alternative Name` information of the CA certificate that issues the user certificate. The information to be specified is consistent with the [`alt_names` of the `openssl.cnf` configuration file](/generate-self-signed-certificates.md) used to generate the client certificate.
291+
+ `require san`: Specifies the `Subject Alternative Name` information of the CA certificate that issues the user certificate. The information to be specified is consistent with the [`alt_names` of the `openssl.cnf` configuration file](https://docs.pingcap.com/tidb/stable/generate-self-signed-certificates) used to generate the client certificate.
282292

283293
+ Execute the following command to get the information of the `require san` item in the generated certificate:
284294

character-set-and-collation.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,12 @@ To disable this error reporting, use `set @@tidb_skip_utf8_check=1;` to skip the
382382

383383
## Collation support framework
384384

385+
<CustomContent platform="tidb">
386+
385387
The syntax support and semantic support for the collation are influenced by the [`new_collations_enabled_on_first_bootstrap`](/tidb-configuration-file.md#new_collations_enabled_on_first_bootstrap) configuration item. The syntax support and semantic support are different. The former indicates that TiDB can parse and set collations. The latter indicates that TiDB can correctly use collations when comparing strings.
386388

389+
</CustomContent>
390+
387391
Before v4.0, TiDB provides only the [old framework for collations](#old-framework-for-collations). In this framework, TiDB supports syntactically parsing most of the MySQL collations but semantically takes all collations as binary collations.
388392

389393
Since v4.0, TiDB supports a [new framework for collations](#new-framework-for-collations). In this framework, TiDB semantically parses different collations and strictly follows the collations when comparing strings.
@@ -407,7 +411,11 @@ Query OK, 1 row affected # In TiDB, it is successfully executed. In MySQL, becau
407411

408412
### New framework for collations
409413

410-
In TiDB 4.0, a complete framework for collations is introduced. This new framework supports semantically parsing collations and introduces the `new_collations_enabled_on_first_bootstrap` configuration item to decide whether to enable the new framework when a cluster is first initialized. To enable the new framework, set `new_collations_enabled_on_first_bootstrap` to `true`. For details, see [`new_collations_enabled_on_first_bootstrap`](/tidb-configuration-file.md#new_collations_enabled_on_first_bootstrap). If you initialize the cluster after the configuration item is enabled, you can check whether the new collation is enabled through the `new_collation_enabled` variable in the `mysql`.`tidb` table:
414+
Since TiDB v4.0, a complete framework for collations is introduced.
415+
416+
<CustomContent platform="tidb">
417+
418+
This new framework supports semantically parsing collations and introduces the `new_collations_enabled_on_first_bootstrap` configuration item to decide whether to enable the new framework when a cluster is first initialized. To enable the new framework, set `new_collations_enabled_on_first_bootstrap` to `true`. For details, see [`new_collations_enabled_on_first_bootstrap`](/tidb-configuration-file.md#new_collations_enabled_on_first_bootstrap). If you initialize the cluster after the configuration item is enabled, you can check whether the new collation is enabled through the `new_collation_enabled` variable in the `mysql`.`tidb` table:
411419

412420
{{< copyable "sql" >}}
413421

@@ -424,6 +432,14 @@ SELECT VARIABLE_VALUE FROM mysql.tidb WHERE VARIABLE_NAME='new_collation_enabled
424432
1 row in set (0.00 sec)
425433
```
426434

435+
</CustomContent>
436+
437+
<CustomContent platform="tidb-cloud">
438+
439+
This new framework supports semantically parsing collations. TiDB enables the new framework by default when a cluster is first initialized.
440+
441+
</CustomContent>
442+
427443
Under the new framework, TiDB supports the `utf8_general_ci`, `utf8mb4_general_ci`, `utf8_unicode_ci`, `utf8mb4_unicode_ci`, `gbk_chinese_ci`, and `gbk_bin` collations, which is compatible with MySQL.
428444

429445
When one of `utf8_general_ci`, `utf8mb4_general_ci`, `utf8_unicode_ci`, `utf8mb4_unicode_ci`, and `gbk_chinese_ci` is used, the string comparison is case-insensitive and accent-insensitive. At the same time, TiDB also corrects the collation's `PADDING` behavior:

character-set-gbk.md

+10
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,18 @@ This section provides the compatibility information between MySQL and TiDB.
3333

3434
The default collation of the GBK character set in MySQL is `gbk_chinese_ci`. Unlike MySQL, the default collation of the GBK character set in TiDB is `gbk_bin`. Additionally, because TiDB converts GBK to UTF8MB4 and then uses a binary collation, the `gbk_bin` collation in TiDB is not the same as the `gbk_bin` collation in MySQL.
3535

36+
<CustomContent platform="tidb">
37+
3638
To make TiDB compatible with the collations of MySQL GBK character set, when you first initialize the TiDB cluster, you need to set the TiDB option [`new_collations_enabled_on_first_bootstrap`](/tidb-configuration-file.md#new_collations_enabled_on_first_bootstrap) to `true` to enable the [new framework for collations](/character-set-and-collation.md#new-framework-for-collations).
3739

40+
</CustomContent>
41+
42+
<CustomContent platform="tidb-cloud">
43+
44+
To make TiDB compatible with the collations of MySQL GBK character set, when you first initialize the TiDB cluster, TiDB Cloud enables the [new framework for collations](/character-set-and-collation.md#new-framework-for-collations) by default.
45+
46+
</CustomContent>
47+
3848
After enabling the new framework for collations, if you check the collations corresponding to the GBK character set, you can see that the TiDB GBK default collation is changed to `gbk_chinese_ci`.
3949

4050
```sql

clustered-indexes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Currently, there are several different types of limitations for the clustered in
148148
- Situations that are not supported yet but in the support plan:
149149
- Adding, dropping, and altering clustered indexes using `ALTER TABLE` statements are not supported.
150150
- Limitations for specific versions:
151-
- In v5.0, using the clustered index feature together with TiDB Binlog is not supported. After TiDB Binlog is enabled, TiDB only allows creating a single integer column as the clustered index of a primary key. TiDB Binlog does not replicate data changes (such as insertion, deletion, and update) on existing tables with clustered indexes to the downstream. If you need to replicate tables with clustered indexes to the downstream, upgrade your cluster to v5.1 or use [TiCDC](/ticdc/ticdc-overview.md) for replication instead.
151+
- In v5.0, using the clustered index feature together with TiDB Binlog is not supported. After TiDB Binlog is enabled, TiDB only allows creating a single integer column as the clustered index of a primary key. TiDB Binlog does not replicate data changes (such as insertion, deletion, and update) on existing tables with clustered indexes to the downstream. If you need to replicate tables with clustered indexes to the downstream, upgrade your cluster to v5.1 or use [TiCDC](https://docs.pingcap.com/tidb/stable/ticdc-overview) for replication instead.
152152

153153
After TiDB Binlog is enabled, if the clustered index you create is not a single integer primary key, TiDB returns the following error:
154154

coprocessor-cache.md

+10
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,18 @@ Starting from v4.0, the TiDB instance supports caching the results of the calcul
1010

1111
## Configuration
1212

13+
<CustomContent platform="tidb">
14+
1315
You can configure Coprocessor Cache via the `tikv-client.copr-cache` configuration items in the TiDB configuration file. For details about how to enable and configure Coprocessor Cache, see [TiDB Configuration File](/tidb-configuration-file.md#tikv-clientcopr-cache-new-in-v400).
1416

17+
</CustomContent>
18+
19+
<CustomContent platform="tidb-cloud">
20+
21+
The Coprocessor Cache feature is enabled by default. The maximum size of the data that can be cached is 1000 MB.
22+
23+
</CustomContent>
24+
1525
## Feature description
1626

1727
+ When a SQL statement is executed on a single TiDB instance for the first time, the execution result is not cached.

enable-tls-between-components.md

+10
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,18 @@ Currently, it is not supported to only enable encrypted transmission of some spe
2323

2424
You can use tools like `openssl`, `easy-rsa` and `cfssl` to generate self-signed certificates.
2525

26+
<CustomContent platform="tidb">
27+
2628
If you choose `openssl`, you can refer to [generating self-signed certificates](/generate-self-signed-certificates.md).
2729

30+
</CustomContent>
31+
32+
<CustomContent platform="tidb-cloud">
33+
34+
If you choose `openssl`, you can refer to [generating self-signed certificates](https://docs.pingcap.com/tidb/stable/generate-self-signed-certificates).
35+
36+
</CustomContent>
37+
2838
2. Configure certificates.
2939

3040
To enable mutual authentication among TiDB components, configure the certificates of TiDB, TiKV, and PD as follows.

explain-views.md

+10
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,18 @@ summary: Learn about the execution plan information returned by the `EXPLAIN` st
77

88
`EXPLAIN` displays the tables and indexes that a [view](/views.md) references, not the name of the view itself. This is because views are only virtual tables and do not store any data themselves. The definition of the view and the rest of the statement are merged together during SQL optimization.
99

10+
<CustomContent platform="tidb">
11+
1012
From the [bikeshare example database](/import-example-data.md), you can see that the following two queries are executed in a similar manner:
1113

14+
</CustomContent>
15+
16+
<CustomContent platform="tidb-cloud">
17+
18+
From the [bikeshare example database](/tidb-cloud/import-sample-data.md), you can see that the following two queries are executed in a similar manner:
19+
20+
</CustomContent>
21+
1222
{{< copyable "sql" >}}
1323

1424
```sql

explain-walkthrough.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@ summary: Learn how to use EXPLAIN by walking through an example statement
77

88
Because SQL is a declarative language, you cannot automatically tell whether a query is executed efficiently. You must first use the [`EXPLAIN`](/sql-statements/sql-statement-explain.md) statement to learn the current execution plan.
99

10-
The following statement from the [bikeshare example database](/import-example-data.md) counts how many trips were taken on the July 1, 2017:
10+
<CustomContent platform="tidb">
11+
12+
The following statement from the [bikeshare example database](/import-example-data.md) counts how many trips were taken on July 1, 2017:
13+
14+
</CustomContent>
15+
16+
<CustomContent platform="tidb-cloud">
17+
18+
The following statement from the [bikeshare example database](/tidb-cloud/import-sample-data.md) counts how many trips were taken on July 1, 2017:
19+
20+
</CustomContent>
1121

1222
{{< copyable "sql" >}}
1323

information-schema/information-schema-deadlocks.md

+22
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,18 @@ The meaning of each column field in the `DEADLOCKS` table is as follows:
4444
* `KEY_INFO`: The detailed information of `KEY`. See the [KEY_INFO](#key_info) section.
4545
* `TRX_HOLDING_LOCK`: The ID of the transaction that currently holds the lock on the key and causes blocking. This ID is also the `start_ts` of the transaction.
4646

47+
<CustomContent platform="tidb">
48+
4749
To adjust the maximum number of deadlock events that can be recorded in the `DEADLOCKS` table, adjust the [`pessimistic-txn.deadlock-history-capacity`](/tidb-configuration-file.md#deadlock-history-capacity) configuration in the TiDB configuration file. By default, the information of the recent 10 deadlock events is recorded in the table.
4850

51+
</CustomContent>
52+
53+
<CustomContent platform="tidb-cloud">
54+
55+
The information of the recent 10 deadlock events is recorded in the `DEADLOCKS` table.
56+
57+
</CustomContent>
58+
4959
> **Warning:**
5060
>
5161
> * Only users with the [PROCESS](https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_process) privilege can query this table.
@@ -78,10 +88,22 @@ In the above fields, if the information of a field is not applicable or currentl
7888
7989
## Retryable deadlock errors
8090

91+
<CustomContent platform="tidb-cloud">
92+
93+
> **Note:**
94+
>
95+
> This section is not applicable to TiDB Cloud.
96+
97+
</CustomContent>
98+
99+
<CustomContent platform="tidb">
100+
81101
> **Note:**
82102
>
83103
> The `DEADLOCKS` table does not collect the information of retryable deadlock errors by default. If you want the table to collect the retryable deadlock error information, you can adjust the value of [`pessimistic-txn.deadlock-history-collect-retryable`](/tidb-configuration-file.md#deadlock-history-collect-retryable) in the TiDB configuration file.
84104
105+
</CustomContent>
106+
85107
When transaction A is blocked by a lock already held by transaction B, and transaction B is directly or indirectly blocked by the lock held by the current transaction A, a deadlock error will occur. In this deadlock, there might be two cases:
86108

87109
+ Case 1: Transaction B might be (directly or indirectly) blocked by a lock generated by a statement that has been executed after transaction A starts and before transaction A gets blocked.

0 commit comments

Comments
 (0)