From 7dcaf943f86be3b8af5fc02e80de04381482e716 Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Mon, 20 Dec 2021 10:53:47 +0800 Subject: [PATCH] sql-statements: update claims on optimizer/explain compatibility (#6695) (#7296) --- mysql-compatibility.md | 6 +++++- sql-statements/sql-statement-explain.md | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mysql-compatibility.md b/mysql-compatibility.md index 1a7b8451ef9eb..93f4e5062e50d 100644 --- a/mysql-compatibility.md +++ b/mysql-compatibility.md @@ -81,7 +81,11 @@ TiDB uses a combination of [Prometheus and Grafana](/tidb-monitoring-api.md) to ### Query Execution Plan -The output format, output content, and the privilege setting of Query Execution Plan (`EXPLAIN`/`EXPLAIN FOR`) in TiDB is greatly different from those in MySQL. See [Understand the Query Execution Plan](/explain-overview.md) for more details. +The output format, output content, and the privilege setting of Query Execution Plan (`EXPLAIN`/`EXPLAIN FOR`) in TiDB is greatly different from those in MySQL. + +The MySQL system variable `optimizer_switch` is read-only in TiDB and has no effect on query plans. You can also use [optimizer hints](/optimizer-hints.md) in similar syntax to MySQL, but the available hints and implementation might differ. + +See [Understand the Query Execution Plan](/explain-overview.md) for more details. ### Built-in functions diff --git a/sql-statements/sql-statement-explain.md b/sql-statements/sql-statement-explain.md index 8aeae67fb9c01..3e457162bd71f 100644 --- a/sql-statements/sql-statement-explain.md +++ b/sql-statements/sql-statement-explain.md @@ -243,10 +243,10 @@ If the `dot` program is not installed on your computer, copy the result to [this ## MySQL compatibility * Both the format of `EXPLAIN` and the potential execution plans in TiDB differ substaintially from MySQL. -* TiDB does not support the `EXPLAIN FORMAT=JSON` as in MySQL. +* TiDB does not support the `FORMAT=JSON` or `FORMAT=TREE` options. * TiDB does not currently support `EXPLAIN` for insert statements. -## `EXPLAIN FOR CONNECTION` +### `EXPLAIN FOR CONNECTION` `EXPLAIN FOR CONNECTION` is used to get the execution plan of the currently executed SQL query or the last executed SQL query in a connection. The output format is the same as that of `EXPLAIN`. However, the implementation of `EXPLAIN FOR CONNECTION` in TiDB is different from that in MySQL. Their differences (apart from the output format) are listed as follows: