You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: agg-distinct-optimization.md
+12-2
Original file line number
Diff line number
Diff line change
@@ -27,9 +27,19 @@ mysql> explain SELECT DISTINCT a from t;
27
27
28
28
Usually, aggregate functions with the `DISTINCT` option is executed in the TiDB layer in a single-threaded execution model.
29
29
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
+
<CustomContentplatform="tidb">
31
31
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
+
<CustomContentplatform="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.
This document introduces the `AUTO_INCREMENT` column attribute, including its concept, implementation principles, auto-increment related features, and restrictions.
10
10
11
+
<CustomContentplatform="tidb">
12
+
11
13
> **Note:**
12
14
>
13
15
> 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.
14
16
17
+
</CustomContent>
18
+
19
+
<CustomContentplatform="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
+
15
27
## Concept
16
28
17
29
`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`has been generally available since v4.0.3.
12
12
13
13
## User scenario
14
14
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
+
<CustomContentplatform="tidb">
18
+
19
+
For more information, see [Highly Concurrent Write Best Practices](/best-practices/high-concurrency-best-practices.md#complex-hotspot-problems).
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).
12
10
13
-
</CustomContent>
14
-
15
-
<CustomContentplatform="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
-
21
11
<CustomContentplatform="tidb">
22
12
23
13
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.
Copy file name to clipboardexpand all lines: certificate-authentication.md
+12-2
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,17 @@ The rest of the document introduces in detail how to perform these operations.
19
19
20
20
## Create security keys and certificates
21
21
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
+
<CustomContentplatform="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
+
<CustomContentplatform="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>
23
33
24
34
### Generate CA key and certificate
25
35
@@ -278,7 +288,7 @@ The user certificate information can be specified by `require subject`, `require
278
288
openssl x509 -noout -subject -in ca-cert.pem | sed 's/.\{8\}//'| sed 's/, /\//g'| sed 's/ = /=/g'| sed 's/^/\//'
279
289
```
280
290
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.
282
292
283
293
+ Execute the following command to get the information of the `require san` item in the generated certificate:
Copy file name to clipboardexpand all lines: character-set-and-collation.md
+17-1
Original file line number
Diff line number
Diff line change
@@ -382,8 +382,12 @@ To disable this error reporting, use `set @@tidb_skip_utf8_check=1;` to skip the
382
382
383
383
## Collation support framework
384
384
385
+
<CustomContent platform="tidb">
386
+
385
387
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.
386
388
389
+
</CustomContent>
390
+
387
391
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.
388
392
389
393
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
407
411
408
412
### New framework for collations
409
413
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:
411
419
412
420
{{< copyable "sql">}}
413
421
@@ -424,6 +432,14 @@ SELECT VARIABLE_VALUE FROM mysql.tidb WHERE VARIABLE_NAME='new_collation_enabled
424
432
1 row in set (0.00 sec)
425
433
```
426
434
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
+
427
443
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.
428
444
429
445
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:
Copy file name to clipboardexpand all lines: character-set-gbk.md
+10
Original file line number
Diff line number
Diff line change
@@ -33,8 +33,18 @@ This section provides the compatibility information between MySQL and TiDB.
33
33
34
34
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.
35
35
36
+
<CustomContentplatform="tidb">
37
+
36
38
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).
37
39
40
+
</CustomContent>
41
+
42
+
<CustomContentplatform="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
+
38
48
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`.
Copy file name to clipboardexpand all lines: clustered-indexes.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -148,7 +148,7 @@ Currently, there are several different types of limitations for the clustered in
148
148
- Situations that are not supported yet but in the support plan:
149
149
- Adding, dropping, and altering clustered indexes using `ALTER TABLE` statements are not supported.
150
150
- 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.
152
152
153
153
After TiDB Binlog is enabled, if the clustered index you create is not a single integer primary key, TiDB returns the following error:
Copy file name to clipboardexpand all lines: coprocessor-cache.md
+10
Original file line number
Diff line number
Diff line change
@@ -10,8 +10,18 @@ Starting from v4.0, the TiDB instance supports caching the results of the calcul
10
10
11
11
## Configuration
12
12
13
+
<CustomContentplatform="tidb">
14
+
13
15
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).
14
16
17
+
</CustomContent>
18
+
19
+
<CustomContentplatform="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
+
15
25
## Feature description
16
26
17
27
+ When a SQL statement is executed on a single TiDB instance for the first time, the execution result is not cached.
Copy file name to clipboardexpand all lines: enable-tls-between-components.md
+10
Original file line number
Diff line number
Diff line change
@@ -23,8 +23,18 @@ Currently, it is not supported to only enable encrypted transmission of some spe
23
23
24
24
You can use tools like `openssl`, `easy-rsa` and `cfssl` to generate self-signed certificates.
25
25
26
+
<CustomContentplatform="tidb">
27
+
26
28
If you choose `openssl`, you can refer to [generating self-signed certificates](/generate-self-signed-certificates.md).
27
29
30
+
</CustomContent>
31
+
32
+
<CustomContentplatform="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
+
28
38
2. Configure certificates.
29
39
30
40
To enable mutual authentication among TiDB components, configure the certificates of TiDB, TiKV, and PD as follows.
Copy file name to clipboardexpand all lines: explain-views.md
+10
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,18 @@ summary: Learn about the execution plan information returned by the `EXPLAIN` st
7
7
8
8
`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.
9
9
10
+
<CustomContentplatform="tidb">
11
+
10
12
From the [bikeshare example database](/import-example-data.md), you can see that the following two queries are executed in a similar manner:
11
13
14
+
</CustomContent>
15
+
16
+
<CustomContentplatform="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:
Copy file name to clipboardexpand all lines: explain-walkthrough.md
+11-1
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,17 @@ summary: Learn how to use EXPLAIN by walking through an example statement
7
7
8
8
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.
9
9
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
+
<CustomContentplatform="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
+
<CustomContentplatform="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:
Copy file name to clipboardexpand all lines: information-schema/information-schema-deadlocks.md
+22
Original file line number
Diff line number
Diff line change
@@ -44,8 +44,18 @@ The meaning of each column field in the `DEADLOCKS` table is as follows:
44
44
*`KEY_INFO`: The detailed information of `KEY`. See the [KEY_INFO](#key_info) section.
45
45
*`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.
46
46
47
+
<CustomContentplatform="tidb">
48
+
47
49
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.
48
50
51
+
</CustomContent>
52
+
53
+
<CustomContentplatform="tidb-cloud">
54
+
55
+
The information of the recent 10 deadlock events is recorded in the `DEADLOCKS` table.
56
+
57
+
</CustomContent>
58
+
49
59
> **Warning:**
50
60
>
51
61
> * 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
78
88
79
89
## Retryable deadlock errors
80
90
91
+
<CustomContentplatform="tidb-cloud">
92
+
93
+
> **Note:**
94
+
>
95
+
> This section is not applicable to TiDB Cloud.
96
+
97
+
</CustomContent>
98
+
99
+
<CustomContentplatform="tidb">
100
+
81
101
> **Note:**
82
102
>
83
103
> 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.
84
104
105
+
</CustomContent>
106
+
85
107
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:
86
108
87
109
+ 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