Skip to content

Commit 4bce1e2

Browse files
authored
sql: Added incompatibilities with MySQL (#604)
* Added incompatibilities with MySQL events, sys do not exist pfs exists but returns empty. * Changed monitoring to performance metrics * Improve unsupported features * Make all items plural * Improved Clarity Remove 'the' from Foreign keys / fulltext / spatial indexes Clarify that it is not non-utf8 characters, but character sets other than utf8. * utf8 as code * Added Storage engines to compatibility * Update mysql-compatibility.md * Added link to --store * Add large transactions and EXPLAIN command * Added Optimizer Trace To differentiate: TiDB has query-tracing, mysql has optimizer tracing. * lowercase t * Include PR605 Add default differences * lower m * Fixed spacing * Addressed PR Feedback * Addressed PR feedback
1 parent 44dbcfb commit 4bce1e2

File tree

1 file changed

+53
-10
lines changed

1 file changed

+53
-10
lines changed

sql/mysql-compatibility.md

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ However, in TiDB, the following MySQL features are not supported for the time be
1414

1515
## Unsupported features
1616

17-
+ Stored Procedures
18-
+ View
19-
+ Trigger
20-
+ The user-defined functions
21-
+ The `FOREIGN KEY` constraints
22-
+ The `FULLTEXT` indexes
23-
+ The `Spatial` indexes
24-
+ The Non-UTF-8 characters
17+
+ Stored procedures and functions
18+
+ Views
19+
+ Triggers
20+
+ Events
21+
+ User-defined functions
22+
+ `FOREIGN KEY` constraints
23+
+ `FULLTEXT` indexes
24+
+ `SPATIAL` indexes
25+
+ Character sets other than `utf8`
2526
+ Add primary key
2627
+ Drop primary key
28+
+ SYS schema
29+
+ Optimizer trace
2730

2831
## Features that are different from MySQL
2932

@@ -50,6 +53,10 @@ The auto-increment ID feature in TiDB is only guaranteed to be automatically inc
5053
> 1. The client issues the `insert into t values (1, 1)` statement to Instance B which sets the `id` to 1 and the statement is executed successfully.
5154
> 2. The client issues the `insert into t (c) (1)` statement to Instance A. This statement does not specify the value of `id`, so Instance A allocates the value. Currently, Instances A caches the auto-increment ID of [1, 30000], so it allocates the `id` value to 1 and adds 1 to the local counter. However, at this time the data with the `id` of 1 already exists in the cluster, therefore it reports `Duplicated Error`.
5255
56+
### Performance schema
57+
58+
Performance schema tables return empty results in TiDB. TiDB uses a combination of [Prometheus and Grafana](https://pingcap.com/docs/op-guide/monitor/#use-prometheus-and-grafana) for performance metrics instead.
59+
5360
### Built-in functions
5461
5562
TiDB supports most of the MySQL built-in functions, but not all. See [TiDB SQL Grammar](https://pingcap.github.io/sqlgram/#FunctionCallKeyword) for the supported functions.
@@ -83,12 +90,20 @@ TiDB implements the asynchronous schema changes algorithm in F1. The Data Manipu
8390
+ Rename Table
8491
+ Create Table Like
8592
86-
### Transaction
93+
### Transaction model
8794
8895
TiDB implements an optimistic transaction model. Unlike MySQL, which uses row-level locking to avoid write conflict, in TiDB, the write conflict is checked only in the `commit` process during the execution of the statements like `Update`, `Insert`, `Delete`, and so on.
8996
9097
**Note:** On the business side, remember to check the returned results of `commit` because even there is no error in the execution, there might be errors in the `commit` process.
9198
99+
### Large transactions
100+
101+
Due to the distributed, 2-phase commit requirement of TiDB, large transactions that modify data can be particularly problematic. TiDB intentionally sets some limits on transaction sizes to reduce this impact:
102+
103+
* Each Key-Value entry is no more than 6MB
104+
* The total number of Key-Value entries is no more than 300,000
105+
* The total size of Key-Value entries is no more than 100MB
106+
92107
### Load data
93108
94109
+ Syntax:
@@ -106,11 +121,39 @@ TiDB implements an optimistic transaction model. Unlike MySQL, which uses row-le
106121
+ Transaction
107122
108123
When TiDB is in the execution of loading data, by default, a record with 20,000 rows of data is seen as a transaction for persistent storage. If a load data operation inserts more than 20,000 rows, it will be divided into multiple transactions to commit. If an error occurs in one transaction, this transaction in process will not be committed. However, transactions before that are committed successfully. In this case, a part of the load data operation is successfully inserted, and the rest of the data insertion fails. But MySQL treats a load data operation as a transaction, one error leads to the failure of the entire load data operation.
124+
125+
### Storage engines
126+
127+
For compatibility reasons, TiDB supports the syntax to create tables with alternative storage engines. Metadata commands describe tables as being of engine InnoDB:
128+
129+
```sql
130+
mysql> CREATE TABLE t1 (a INT) ENGINE=MyISAM;
131+
Query OK, 0 rows affected (0.14 sec)
132+
133+
mysql> SHOW CREATE TABLE t1\G
134+
*************************** 1. row ***************************
135+
Table: t1
136+
Create Table: CREATE TABLE `t1` (
137+
`a` int(11) DEFAULT NULL
138+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
139+
1 row in set (0.00 sec)
140+
```
141+
142+
Architecturally, TiDB does support a similar storage engine abstraction to MySQL, user tables are be created in the engine specified by the [`--store`](server-command-option.md#--store) option used when starting tidb-server (typically `tikv`).
143+
144+
### EXPLAIN
145+
146+
The output of the query execution plan returned from the `EXPLAIN` command differs from MySQL. For more information, see [Understand the Query Execution Plan](understanding-the-query-execution-plan.md).
109147

110148
### Default differences
111149

112-
- Default character set: `latin1` in MySQL 5.7 (UTF-8 in MySQL 8.0), while `utf8mb4` in TiDB.
150+
- Default character set:
151+
- The default value in TiDB is `utf8` which is equivalent to `utf8mb4` in MySQL.
152+
- The default value in MySQL 5.7 is `latin1`, but changes to `utf8mb4` in MySQL 8.0.
113153
- Default collation: `latin1_swedish_ci` in MySQL 5.7, while `binary` in TiDB.
154+
- Default SQL mode:
155+
- The default value in TiDB is `STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION`.
156+
- The default value in MySQL 5.7 is `ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION`.
114157
- Default value of `lower_case_table_names`:
115158
- The default value in TiDB is 2 and currently TiDB only supports 2.
116159
- The default value in MySQL:

0 commit comments

Comments
 (0)