From 0d1074447474c53ae939183eedc6adc05530b0df Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Fri, 18 Jun 2021 18:01:49 +0800 Subject: [PATCH 01/17] add docs for enforce mpp --- system-variables.md | 17 +++++++++++-- tidb-configuration-file.md | 6 +++++ tiflash/use-tiflash.md | 49 +++++++++++++++++++++++++++++++++++--- 3 files changed, 67 insertions(+), 5 deletions(-) diff --git a/system-variables.md b/system-variables.md index 98c2880c639c4..71cf09cee8ac0 100644 --- a/system-variables.md +++ b/system-variables.md @@ -205,8 +205,11 @@ mysql> SELECT * FROM t1; - Scope: SESSION | GLOBAL - Default value: `ON` -- Possible values: `OFF`, `ON`, `ENFORCE` -- This variable controls whether to use the MPP mode of TiFlash to execute queries. If the value is set to `ON`, TiDB automatically determines using the optimizer whether to choose MPP to execute queries. MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. +- This variable controls whether to use the MPP mode of TiFlash to execute queries. You can set the following values, including: + - `0` or `OFF`, which means never use MPP mode. + - `1` or `ON`, which means that the optimizer determines whether to use MPP mode based on cost estimation (by default). + +MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about MPP mode selection, refer to [Control whether to choose the MPP mode](/tiflash/use-tiflash.md#control-whether-to-choose-the-mpp-mode). ### tidb_allow_remove_auto_inc New in v2.1.18 and v3.0.4 @@ -605,6 +608,16 @@ Query OK, 0 rows affected (0.09 sec) - Default value: `ON` - This variable is used to control whether to enable the support for window functions. Note that window functions may use reserved keywords. This might cause SQL statements that could be executed normally cannot be parsed after upgrading TiDB. In this case, you can set `tidb_enable_window_function` to `OFF`. +### `tidb_enforce_mpp` New in v5.1 + +- Scope: SESSION +- Default value: `OFF` +- This variable is used to control whether to ignore the optimizer cost estimation, and to force the use of TiFlash's MPP mode to execute the queries. You can set the following values: + - `0` or `OFF`, which means MPP mode is not mandatory (default). + - `1` or `ON`, which means that cost estimation is ignored and MPP mode is forced. Note that this setting only takes effect when `tidb_allow_mpp=true`. + +MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about MPP mode selection, refer to [Control whether to choose the MPP mode](/tiflash/use-tiflash.md#control-whether-to-choose-the-mpp-mode). + ### tidb_evolve_plan_baselines New in v4.0 - Scope: SESSION | GLOBAL diff --git a/tidb-configuration-file.md b/tidb-configuration-file.md index 48a9b443d261f..99e0b182e4eb0 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -438,6 +438,12 @@ Configuration items related to performance. + Default value: `20971520` + When `nested-loop-join-cache-capacity` is set to `0`, nested loop join cache is disabled by default. When the LRU size is larger than the value of `nested-loop-join-cache-capacity`, the elements in the LRU are removed. +### `enforce-mpp` + ++ Determines whether to ignore the optimizer cost estimate, and force TiFlash's MPP mode to execute queries. ++ Default value: `false` ++ This configuration item is the initial value of [`tidb_enforce_mpp`](/system-variables.md#tidb-enforce-mpp-new-in-v51). + ## prepared-plan-cache The Plan Cache configuration of the `PREPARE` statement. diff --git a/tiflash/use-tiflash.md b/tiflash/use-tiflash.md index 0c417a2304dde..47ea6daadc2ae 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -258,12 +258,55 @@ If a query encounters unsupported push-down calculations, TiDB needs to complete ## Use the MPP mode -TiFlash supports using the MPP mode to execute queries, which introduces cross-node data exchange (data shuffle process) into the computation. The MPP mode is enabled by default and can be disabled by setting the value of the global/session variable [`tidb_allow_mpp`](/system-variables.md#tidb_allow_mpp-new-in-v50) to `0` or `OFF`. +TiFlash supports using the MPP mode to execute queries, which introduces cross-node data exchange (data shuffle process) into the computation. TiDB automatically determines using the optimizer whether to choose MPP mode. You can change the selection strategy by modifying the values of [`tidb_allow_mpp`](/system-variables.md#tidb-allow-mpp-new-in-v50) and [`tidb_enforce_mpp`](/system-variables.md#tidb-enforce-mpp-new-in-v51). -```shell -set @@session.tidb_allow_mpp=0 +### Control whether to choose the MPP mode + +`tidb_allow_mpp` controls whether TiDB can select MPP mode to execute queries. `tidb_enforce_mpp` controls whether the optimizer cost estimate is ignored and TiFlash's MPP mode is forced to execute queries. + +The results corresponding to all values of these two variables are as follows: + +| | tidb_allow_mpp=off | tidb_allow_mpp=on (by default) | +| ---------------------- | -------------------- | -------------------------------- | +| tidb_enforce_mpp=off (by default) | MPP mode is not used. | The optimizer selects based on cost estimation. (by default)| +| tidb_enforce_mpp=on | MPP mode is not used. | TiDB ignores the cost estimate and selects MPP mode. | + +For example, if you do not want to use MPP mode, you can set by executing the following statement: + +{{< copyable "sql" >}} + +```sql +set @@session.tidb_allow_mpp=1; +set @@session.tidb_enforce_mpp=0; ``` +The initial value of the Session variable `tidb_enforce_mpp` is equal to the[`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration item value of this tidb-server instance (which is `false` by default). In a TiDB cluster, if several tidb-server instances only perform analytical queries, to ensure that they can check MPP mode, you can change their [`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration value to `true`. + +> **Note:** +> +> When `tidb_enforce_mpp=1` takes effect, the TiDB optimizer will ignore the cost estimate to select MPP mode. However, TiDB will not select MPP mode if other factors that do not support MPP mode occur, such as no TiFlash copy, the replication of TiFlash copies is not completed, and the statements contain operators or functions that are not supported by MPP mode. +> +> If the TiDB optimizer cannot select MPP mode due to reasons other than cost estimation, when you use the `EXPLAIN` statement to view the execution plan, a warning is returned to explain the reason, for example: +> +> {{< copyable "sql" >}} +> +> ```sql +> set @@session.tidb_enforce_mpp=1; +> create table t(a int); +> explain select count(*) from t; +> show warnings; +> ``` +> +> ``` +> +---------+------+-----------------------------------------------------------------------------+ +> | Level | Code | Message | +> +---------+------+-----------------------------------------------------------------------------+ +> | Warning | 1105 | MPP mode may be blocked because there aren't tiflash replicas of table `t`. | +> +---------+------+-----------------------------------------------------------------------------+ +> ``` + +### Algorithm support for MPP mode + MPP mode supports these physical algorithms: Broadcast Hash Join, Shuffled Hash Join, Shuffled Hash Aggregation, Union All, TopN, and Limit. The optimizer automatically determines which algorithm to be used in a query. To check the specific query execution plan, you can execute the `EXPLAIN` statement. If the result of the `EXPLAIN` statement shows ExchangeSender and ExchangeReceiver operators, it indicates that the MPP mode has taken effect. The following statement takes the table structure in the TPC-H test set as an example: From 51ca0eeb78e161a032ef171cce99f823c6df5d72 Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Fri, 18 Jun 2021 18:16:41 +0800 Subject: [PATCH 02/17] fix links --- tidb-configuration-file.md | 2 +- tiflash/use-tiflash.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tidb-configuration-file.md b/tidb-configuration-file.md index 99e0b182e4eb0..41083d1930a17 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -442,7 +442,7 @@ Configuration items related to performance. + Determines whether to ignore the optimizer cost estimate, and force TiFlash's MPP mode to execute queries. + Default value: `false` -+ This configuration item is the initial value of [`tidb_enforce_mpp`](/system-variables.md#tidb-enforce-mpp-new-in-v51). ++ This configuration item is the initial value of [`tidb_enforce_mpp`](/system-variables.md#tidb_enforce_mpp-new-in-v51). ## prepared-plan-cache diff --git a/tiflash/use-tiflash.md b/tiflash/use-tiflash.md index 47ea6daadc2ae..da034fd9dcee3 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -258,7 +258,7 @@ If a query encounters unsupported push-down calculations, TiDB needs to complete ## Use the MPP mode -TiFlash supports using the MPP mode to execute queries, which introduces cross-node data exchange (data shuffle process) into the computation. TiDB automatically determines using the optimizer whether to choose MPP mode. You can change the selection strategy by modifying the values of [`tidb_allow_mpp`](/system-variables.md#tidb-allow-mpp-new-in-v50) and [`tidb_enforce_mpp`](/system-variables.md#tidb-enforce-mpp-new-in-v51). +TiFlash supports using the MPP mode to execute queries, which introduces cross-node data exchange (data shuffle process) into the computation. TiDB automatically determines using the optimizer whether to choose MPP mode. You can change the selection strategy by modifying the values of [`tidb_allow_mpp`](/system-variables.md#tidb_allow_mpp-new-in-v50) and [`tidb_enforce_mpp`](/system-variables.md#tidb_enforce_mpp-new-in-v51). ### Control whether to choose the MPP mode From 1748f1b4bd5ecf826d84e771fecc60c380fa842c Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Mon, 21 Jun 2021 11:04:07 +0800 Subject: [PATCH 03/17] update --- system-variables.md | 4 ++-- tidb-configuration-file.md | 2 +- tiflash/use-tiflash.md | 32 +++++++++++++++++++++++++------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/system-variables.md b/system-variables.md index 71cf09cee8ac0..e713e29f3ca0c 100644 --- a/system-variables.md +++ b/system-variables.md @@ -207,7 +207,7 @@ mysql> SELECT * FROM t1; - Default value: `ON` - This variable controls whether to use the MPP mode of TiFlash to execute queries. You can set the following values, including: - `0` or `OFF`, which means never use MPP mode. - - `1` or `ON`, which means that the optimizer determines whether to use MPP mode based on cost estimation (by default). + - `1` or `ON`, which means that the optimizer determines whether to use MPP mode based on the cost estimation (by default). MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about MPP mode selection, refer to [Control whether to choose the MPP mode](/tiflash/use-tiflash.md#control-whether-to-choose-the-mpp-mode). @@ -614,7 +614,7 @@ Query OK, 0 rows affected (0.09 sec) - Default value: `OFF` - This variable is used to control whether to ignore the optimizer cost estimation, and to force the use of TiFlash's MPP mode to execute the queries. You can set the following values: - `0` or `OFF`, which means MPP mode is not mandatory (default). - - `1` or `ON`, which means that cost estimation is ignored and MPP mode is forced. Note that this setting only takes effect when `tidb_allow_mpp=true`. + - `1` or `ON`, which means that the cost estimation is ignored and MPP mode is mandatory to use. Note that this setting only takes effect when `tidb_allow_mpp=true`. MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about MPP mode selection, refer to [Control whether to choose the MPP mode](/tiflash/use-tiflash.md#control-whether-to-choose-the-mpp-mode). diff --git a/tidb-configuration-file.md b/tidb-configuration-file.md index 41083d1930a17..2a25da2f6eadd 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -440,7 +440,7 @@ Configuration items related to performance. ### `enforce-mpp` -+ Determines whether to ignore the optimizer cost estimate, and force TiFlash's MPP mode to execute queries. ++ Determines whether to ignore the optimizer cost estimation, and force TiFlash's MPP mode to execute queries. + Default value: `false` + This configuration item is the initial value of [`tidb_enforce_mpp`](/system-variables.md#tidb_enforce_mpp-new-in-v51). diff --git a/tiflash/use-tiflash.md b/tiflash/use-tiflash.md index da034fd9dcee3..57c6d47e5772a 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -258,20 +258,20 @@ If a query encounters unsupported push-down calculations, TiDB needs to complete ## Use the MPP mode -TiFlash supports using the MPP mode to execute queries, which introduces cross-node data exchange (data shuffle process) into the computation. TiDB automatically determines using the optimizer whether to choose MPP mode. You can change the selection strategy by modifying the values of [`tidb_allow_mpp`](/system-variables.md#tidb_allow_mpp-new-in-v50) and [`tidb_enforce_mpp`](/system-variables.md#tidb_enforce_mpp-new-in-v51). +TiFlash supports using the MPP mode to execute queries, which introduces cross-node data exchange (data shuffle process) into the computation. TiDB automatically determines whether to choose the MPP mode using the optimizer. You can change the selection strategy by modifying the values of [`tidb_allow_mpp`](/system-variables.md#tidb_allow_mpp-new-in-v50) and [`tidb_enforce_mpp`](/system-variables.md#tidb_enforce_mpp-new-in-v51). ### Control whether to choose the MPP mode -`tidb_allow_mpp` controls whether TiDB can select MPP mode to execute queries. `tidb_enforce_mpp` controls whether the optimizer cost estimate is ignored and TiFlash's MPP mode is forced to execute queries. +`tidb_allow_mpp` controls whether TiDB can select MPP mode to execute queries. `tidb_enforce_mpp` controls whether the optimizer cost estimate is ignored and the MPP mode of TiFlash is forced to execute queries. The results corresponding to all values of these two variables are as follows: | | tidb_allow_mpp=off | tidb_allow_mpp=on (by default) | | ---------------------- | -------------------- | -------------------------------- | -| tidb_enforce_mpp=off (by default) | MPP mode is not used. | The optimizer selects based on cost estimation. (by default)| -| tidb_enforce_mpp=on | MPP mode is not used. | TiDB ignores the cost estimate and selects MPP mode. | +| tidb_enforce_mpp=off (by default) | MPP mode is not used. | The optimizer selects the MPP mode based on cost estimation. (by default)| +| tidb_enforce_mpp=on | MPP mode is not used. | TiDB ignores the cost estimate and chooses MPP mode. | -For example, if you do not want to use MPP mode, you can set by executing the following statement: +For example, if you do not want to use MPP mode, you can execute the following statement: {{< copyable "sql" >}} @@ -280,11 +280,29 @@ set @@session.tidb_allow_mpp=1; set @@session.tidb_enforce_mpp=0; ``` -The initial value of the Session variable `tidb_enforce_mpp` is equal to the[`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration item value of this tidb-server instance (which is `false` by default). In a TiDB cluster, if several tidb-server instances only perform analytical queries, to ensure that they can check MPP mode, you can change their [`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration value to `true`. +If you want to automatically choose whether or not to use the MPP mode (by default) using the cost estimation of TiDB optimizer, you can execute the following statement: + +{{< copyable "sql" >}} + +```sql +set @@session.tidb_allow_mpp=1; +set @@session.tidb_enforce_mpp=0; +``` + +If you want TiDB to ignore the optimizer's cost estimates and force to choose the MPP mode, you can execute the following statement: + +{{< copyable "sql" >}} + +```sql +set @@session.tidb_allow_mpp=1; +set @@session.tidb_enforce_mpp=1; +``` + +The initial value of the Session variable `tidb_enforce_mpp` is equal to the[`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration item value of this tidb-server instance (which is `false` by default). In a TiDB cluster, if several tidb-server instances only perform analytical queries, to ensure that they can choose MPP mode, you can change their [`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration value to `true`. > **Note:** > -> When `tidb_enforce_mpp=1` takes effect, the TiDB optimizer will ignore the cost estimate to select MPP mode. However, TiDB will not select MPP mode if other factors that do not support MPP mode occur, such as no TiFlash copy, the replication of TiFlash copies is not completed, and the statements contain operators or functions that are not supported by MPP mode. +> When `tidb_enforce_mpp=1` takes effect, the TiDB optimizer will ignore the cost estimation to choose MPP mode. However, TiDB will not choose the MPP mode if other factors that do not support the MPP mode occur, such as no TiFlash copy, the replication of TiFlash copies is not completed, and statements contain operators or functions that are not supported by the MPP mode. > > If the TiDB optimizer cannot select MPP mode due to reasons other than cost estimation, when you use the `EXPLAIN` statement to view the execution plan, a warning is returned to explain the reason, for example: > From b0f8a4a9f4b2cb37a9f9be0e6ad50894b29bfa92 Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Mon, 21 Jun 2021 11:06:57 +0800 Subject: [PATCH 04/17] Update use-tiflash.md --- tiflash/use-tiflash.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiflash/use-tiflash.md b/tiflash/use-tiflash.md index 57c6d47e5772a..f0f1fb26f0def 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -280,7 +280,7 @@ set @@session.tidb_allow_mpp=1; set @@session.tidb_enforce_mpp=0; ``` -If you want to automatically choose whether or not to use the MPP mode (by default) using the cost estimation of TiDB optimizer, you can execute the following statement: +If you want to intelligently choose whether to use the MPP mode (by default) using the cost estimation of TiDB optimizer, you can execute the following statement: {{< copyable "sql" >}} From a727177d177c33b90caa5f00c6ebc538d1341409 Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Mon, 21 Jun 2021 12:55:30 +0800 Subject: [PATCH 05/17] refine --- system-variables.md | 2 +- tidb-configuration-file.md | 2 +- tiflash/use-tiflash.md | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/system-variables.md b/system-variables.md index e713e29f3ca0c..f78c69eb1839b 100644 --- a/system-variables.md +++ b/system-variables.md @@ -612,7 +612,7 @@ Query OK, 0 rows affected (0.09 sec) - Scope: SESSION - Default value: `OFF` -- This variable is used to control whether to ignore the optimizer cost estimation, and to force the use of TiFlash's MPP mode to execute the queries. You can set the following values: +- This variable is used to control whether to ignore the optimizer cost estimation and force queries to be executed using TiFlash's MPP mode. You can set the following values: - `0` or `OFF`, which means MPP mode is not mandatory (default). - `1` or `ON`, which means that the cost estimation is ignored and MPP mode is mandatory to use. Note that this setting only takes effect when `tidb_allow_mpp=true`. diff --git a/tidb-configuration-file.md b/tidb-configuration-file.md index 2a25da2f6eadd..1ad603eafec5e 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -440,7 +440,7 @@ Configuration items related to performance. ### `enforce-mpp` -+ Determines whether to ignore the optimizer cost estimation, and force TiFlash's MPP mode to execute queries. ++ Determines whether to ignore the optimizer cost estimation and force TiFlash's MPP mode to execute queries. + Default value: `false` + This configuration item is the initial value of [`tidb_enforce_mpp`](/system-variables.md#tidb_enforce_mpp-new-in-v51). diff --git a/tiflash/use-tiflash.md b/tiflash/use-tiflash.md index f0f1fb26f0def..10b243d3f6f81 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -271,7 +271,7 @@ The results corresponding to all values of these two variables are as follows: | tidb_enforce_mpp=off (by default) | MPP mode is not used. | The optimizer selects the MPP mode based on cost estimation. (by default)| | tidb_enforce_mpp=on | MPP mode is not used. | TiDB ignores the cost estimate and chooses MPP mode. | -For example, if you do not want to use MPP mode, you can execute the following statement: +For example, if you do not want to use MPP mode, you can execute the following statements: {{< copyable "sql" >}} @@ -280,7 +280,7 @@ set @@session.tidb_allow_mpp=1; set @@session.tidb_enforce_mpp=0; ``` -If you want to intelligently choose whether to use the MPP mode (by default) using the cost estimation of TiDB optimizer, you can execute the following statement: +If you want to use the cost estimation of TiDB optimizer to intelligently choose whether to use MPP mode(by default), you can execute the following statements: {{< copyable "sql" >}} @@ -289,7 +289,7 @@ set @@session.tidb_allow_mpp=1; set @@session.tidb_enforce_mpp=0; ``` -If you want TiDB to ignore the optimizer's cost estimates and force to choose the MPP mode, you can execute the following statement: +If you want TiDB to ignore the optimizer's cost estimations and force to choose the MPP mode, you can execute the following statements: {{< copyable "sql" >}} @@ -298,7 +298,7 @@ set @@session.tidb_allow_mpp=1; set @@session.tidb_enforce_mpp=1; ``` -The initial value of the Session variable `tidb_enforce_mpp` is equal to the[`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration item value of this tidb-server instance (which is `false` by default). In a TiDB cluster, if several tidb-server instances only perform analytical queries, to ensure that they can choose MPP mode, you can change their [`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration value to `true`. +The initial value of the session variable `tidb_enforce_mpp` is equal to the[`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration item value of this tidb-server instance (which is `false` by default). If you want to make several tidb servers only serve analytical quries in a TiDB cluster and to force them to use MPP mode, you can change their [`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration value to `true`. > **Note:** > From a14bb6434d1a7c61c0f10ae77e0f77ef1d0e9edb Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Mon, 21 Jun 2021 13:04:26 +0800 Subject: [PATCH 06/17] update --- system-variables.md | 2 +- tiflash/use-tiflash.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/system-variables.md b/system-variables.md index f78c69eb1839b..e17aa11943905 100644 --- a/system-variables.md +++ b/system-variables.md @@ -614,7 +614,7 @@ Query OK, 0 rows affected (0.09 sec) - Default value: `OFF` - This variable is used to control whether to ignore the optimizer cost estimation and force queries to be executed using TiFlash's MPP mode. You can set the following values: - `0` or `OFF`, which means MPP mode is not mandatory (default). - - `1` or `ON`, which means that the cost estimation is ignored and MPP mode is mandatory to use. Note that this setting only takes effect when `tidb_allow_mpp=true`. + - `1` or `ON`, which means that the cost estimation is ignored and MPP mode is forced to use. Note that this setting only takes effect when `tidb_allow_mpp=true`. MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about MPP mode selection, refer to [Control whether to choose the MPP mode](/tiflash/use-tiflash.md#control-whether-to-choose-the-mpp-mode). diff --git a/tiflash/use-tiflash.md b/tiflash/use-tiflash.md index 10b243d3f6f81..c932c51d85a8e 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -280,7 +280,7 @@ set @@session.tidb_allow_mpp=1; set @@session.tidb_enforce_mpp=0; ``` -If you want to use the cost estimation of TiDB optimizer to intelligently choose whether to use MPP mode(by default), you can execute the following statements: +If you want to use the cost estimation of TiDB optimizer to intelligently choose whether to use MPP mode (by default), you can execute the following statements: {{< copyable "sql" >}} @@ -302,9 +302,9 @@ The initial value of the session variable `tidb_enforce_mpp` is equal to the[`en > **Note:** > -> When `tidb_enforce_mpp=1` takes effect, the TiDB optimizer will ignore the cost estimation to choose MPP mode. However, TiDB will not choose the MPP mode if other factors that do not support the MPP mode occur, such as no TiFlash copy, the replication of TiFlash copies is not completed, and statements contain operators or functions that are not supported by the MPP mode. +> When `tidb_enforce_mpp=1` takes effect, the TiDB optimizer will ignore the cost estimation to choose MPP mode. However, TiDB will not choose the MPP mode if other factors that do not support the MPP mode occur, such as no TiFlash replica, the replication of TiFlash replicas is not completed, and statements contain operators or functions that are not supported by MPP mode. > -> If the TiDB optimizer cannot select MPP mode due to reasons other than cost estimation, when you use the `EXPLAIN` statement to view the execution plan, a warning is returned to explain the reason, for example: +> If TiDB optimizer cannot select MPP mode due to reasons other than cost estimation, when you use the `EXPLAIN` statement to view the execution plan, a warning is returned to explain the reason. For example: > > {{< copyable "sql" >}} > From 72236cc5e038fc7a5d6b4afdc4bff66c3d394896 Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Mon, 21 Jun 2021 13:07:40 +0800 Subject: [PATCH 07/17] Update use-tiflash.md --- tiflash/use-tiflash.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiflash/use-tiflash.md b/tiflash/use-tiflash.md index c932c51d85a8e..faf7ed9bc17e6 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -302,7 +302,7 @@ The initial value of the session variable `tidb_enforce_mpp` is equal to the[`en > **Note:** > -> When `tidb_enforce_mpp=1` takes effect, the TiDB optimizer will ignore the cost estimation to choose MPP mode. However, TiDB will not choose the MPP mode if other factors that do not support the MPP mode occur, such as no TiFlash replica, the replication of TiFlash replicas is not completed, and statements contain operators or functions that are not supported by MPP mode. +> When `tidb_enforce_mpp=1` takes effect, TiDB optimizer will ignore the cost estimation to choose MPP mode. However, TiDB will not select MPP mode if there are other factors that block MPP mode, such as no TiFlash replica, the replication of TiFlash replicas is not completed, and statements contain operators or functions that are not supported by MPP mode. > > If TiDB optimizer cannot select MPP mode due to reasons other than cost estimation, when you use the `EXPLAIN` statement to view the execution plan, a warning is returned to explain the reason. For example: > From 7ee3099642a97d0d1d29fd2decb8f9556dbb85e3 Mon Sep 17 00:00:00 2001 From: JoyinQ <56883733+Joyinqin@users.noreply.github.com> Date: Mon, 21 Jun 2021 14:14:27 +0800 Subject: [PATCH 08/17] Apply suggestions from code review Co-authored-by: Zhi Qi <30543181+LittleFall@users.noreply.github.com> --- tiflash/use-tiflash.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiflash/use-tiflash.md b/tiflash/use-tiflash.md index faf7ed9bc17e6..b2a8f4090b26b 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -298,7 +298,7 @@ set @@session.tidb_allow_mpp=1; set @@session.tidb_enforce_mpp=1; ``` -The initial value of the session variable `tidb_enforce_mpp` is equal to the[`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration item value of this tidb-server instance (which is `false` by default). If you want to make several tidb servers only serve analytical quries in a TiDB cluster and to force them to use MPP mode, you can change their [`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration value to `true`. +The initial value of the session variable `tidb_enforce_mpp` is equal to the [`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration item value of this tidb-server instance (which is `false` by default). If you want to make several tidb servers only serve analytical quries in a TiDB cluster and to force them to use MPP mode, you can change their [`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration value to `true`. > **Note:** > From d6cb92f26f9ec04d5ffeefc2679705f2ec777f4f Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Mon, 21 Jun 2021 14:14:56 +0800 Subject: [PATCH 09/17] Update system-variables.md --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index e17aa11943905..2db275882d445 100644 --- a/system-variables.md +++ b/system-variables.md @@ -613,7 +613,7 @@ Query OK, 0 rows affected (0.09 sec) - Scope: SESSION - Default value: `OFF` - This variable is used to control whether to ignore the optimizer cost estimation and force queries to be executed using TiFlash's MPP mode. You can set the following values: - - `0` or `OFF`, which means MPP mode is not mandatory (default). + - `0` or `OFF`, which means MPP mode is not mandatory (by default). - `1` or `ON`, which means that the cost estimation is ignored and MPP mode is forced to use. Note that this setting only takes effect when `tidb_allow_mpp=true`. MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about MPP mode selection, refer to [Control whether to choose the MPP mode](/tiflash/use-tiflash.md#control-whether-to-choose-the-mpp-mode). From 4db3dd33a57371051e545311c8a86e3fcbb98c77 Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Mon, 21 Jun 2021 15:40:31 +0800 Subject: [PATCH 10/17] Update use-tiflash.md --- tiflash/use-tiflash.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiflash/use-tiflash.md b/tiflash/use-tiflash.md index b2a8f4090b26b..7fe17fe0ce158 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -302,7 +302,7 @@ The initial value of the session variable `tidb_enforce_mpp` is equal to the [`e > **Note:** > -> When `tidb_enforce_mpp=1` takes effect, TiDB optimizer will ignore the cost estimation to choose MPP mode. However, TiDB will not select MPP mode if there are other factors that block MPP mode, such as no TiFlash replica, the replication of TiFlash replicas is not completed, and statements contain operators or functions that are not supported by MPP mode. +> When `tidb_enforce_mpp=1` takes effect, TiDB optimizer will ignore the cost estimation to choose MPP mode. However, TiDB will not select MPP mode if other factors block MPP mode, such as no TiFlash replica, the replication of TiFlash replicas is not completed, and statements contain operators or functions that are not supported by MPP mode. > > If TiDB optimizer cannot select MPP mode due to reasons other than cost estimation, when you use the `EXPLAIN` statement to view the execution plan, a warning is returned to explain the reason. For example: > From cb1a3ca4299650c9ffdd674c9288e7aee30e4b42 Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Mon, 21 Jun 2021 19:26:47 +0800 Subject: [PATCH 11/17] update --- system-variables.md | 8 ++++---- tiflash/use-tiflash.md | 30 +++++++++++++++--------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/system-variables.md b/system-variables.md index 2db275882d445..272c87e672cc2 100644 --- a/system-variables.md +++ b/system-variables.md @@ -209,7 +209,7 @@ mysql> SELECT * FROM t1; - `0` or `OFF`, which means never use MPP mode. - `1` or `ON`, which means that the optimizer determines whether to use MPP mode based on the cost estimation (by default). -MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about MPP mode selection, refer to [Control whether to choose the MPP mode](/tiflash/use-tiflash.md#control-whether-to-choose-the-mpp-mode). +MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about the MPP mode selection, refer to [Control whether to select the MPP mode](/tiflash/use-tiflash.md#control-whether-to-select-the-mpp-mode). ### tidb_allow_remove_auto_inc New in v2.1.18 and v3.0.4 @@ -613,10 +613,10 @@ Query OK, 0 rows affected (0.09 sec) - Scope: SESSION - Default value: `OFF` - This variable is used to control whether to ignore the optimizer cost estimation and force queries to be executed using TiFlash's MPP mode. You can set the following values: - - `0` or `OFF`, which means MPP mode is not mandatory (by default). - - `1` or `ON`, which means that the cost estimation is ignored and MPP mode is forced to use. Note that this setting only takes effect when `tidb_allow_mpp=true`. + - `0` or `OFF`, which means the MPP mode is not mandatory (by default). + - `1` or `ON`, which means that the cost estimation is ignored and the MPP mode is forced to use. Note that this setting only takes effect when `tidb_allow_mpp=true`. -MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about MPP mode selection, refer to [Control whether to choose the MPP mode](/tiflash/use-tiflash.md#control-whether-to-choose-the-mpp-mode). +MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about the MPP mode selection, refer to [Control whether to select the MPP mode](/tiflash/use-tiflash.md#control-whether-to-select-the-mpp-mode). ### tidb_evolve_plan_baselines New in v4.0 diff --git a/tiflash/use-tiflash.md b/tiflash/use-tiflash.md index 7fe17fe0ce158..796e73d536515 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -192,7 +192,7 @@ In the above three ways of reading TiFlash replicas, engine isolation specifies > **Note:** > -> Before v4.0.3, the behavior of reading from TiFlash replica in a non-read-only SQL statement (for example, `INSERT INTO ... SELECT`, `SELECT ... FOR UPDATE`, `UPDATE ...`, `DELETE ...`) is undefined. In v4.0.3 and later versions, internally TiDB ignores the TiFlash replica for a non-read-only SQL statement to guarantee the data correctness. That is, for [smart selection](#smart-selection), TiDB automatically chooses the non-TiFlash replica; for [engine isolation](#engine-isolation) that specifies TiFlash replica **only**, TiDB reports an error; and for [manual hint](#manual-hint), TiDB ignores the hint. +> Before v4.0.3, the behavior of reading from TiFlash replica in a non-read-only SQL statement (for example, `INSERT INTO ... SELECT`, `SELECT ... FOR UPDATE`, `UPDATE ...`, `DELETE ...`) is undefined. In v4.0.3 and later versions, internally TiDB ignores the TiFlash replica for a non-read-only SQL statement to guarantee the data correctness. That is, for [smart selection](#smart-selection), TiDB automatically selects the non-TiFlash replica; for [engine isolation](#engine-isolation) that specifies TiFlash replica **only**, TiDB reports an error; and for [manual hint](#manual-hint), TiDB ignores the hint. ## Use TiSpark to read TiFlash replicas @@ -258,20 +258,20 @@ If a query encounters unsupported push-down calculations, TiDB needs to complete ## Use the MPP mode -TiFlash supports using the MPP mode to execute queries, which introduces cross-node data exchange (data shuffle process) into the computation. TiDB automatically determines whether to choose the MPP mode using the optimizer. You can change the selection strategy by modifying the values of [`tidb_allow_mpp`](/system-variables.md#tidb_allow_mpp-new-in-v50) and [`tidb_enforce_mpp`](/system-variables.md#tidb_enforce_mpp-new-in-v51). +TiFlash supports using the MPP mode to execute queries, which introduces cross-node data exchange (data shuffle process) into the computation. TiDB automatically determines whether to select the MPP mode using the optimizer. You can change the selection strategy by modifying the values of [`tidb_allow_mpp`](/system-variables.md#tidb_allow_mpp-new-in-v50) and [`tidb_enforce_mpp`](/system-variables.md#tidb_enforce_mpp-new-in-v51). -### Control whether to choose the MPP mode +### Control whether to select the MPP mode -`tidb_allow_mpp` controls whether TiDB can select MPP mode to execute queries. `tidb_enforce_mpp` controls whether the optimizer cost estimate is ignored and the MPP mode of TiFlash is forced to execute queries. +`tidb_allow_mpp` controls whether TiDB can select the MPP mode to execute queries. `tidb_enforce_mpp` controls whether the optimizer cost estimate is ignored and the MPP mode of TiFlash is forced to execute queries. The results corresponding to all values of these two variables are as follows: | | tidb_allow_mpp=off | tidb_allow_mpp=on (by default) | | ---------------------- | -------------------- | -------------------------------- | -| tidb_enforce_mpp=off (by default) | MPP mode is not used. | The optimizer selects the MPP mode based on cost estimation. (by default)| -| tidb_enforce_mpp=on | MPP mode is not used. | TiDB ignores the cost estimate and chooses MPP mode. | +| tidb_enforce_mpp=off (by default) | The MPP mode is not used. | The optimizer selects the MPP mode based on cost estimation. (by default)| +| tidb_enforce_mpp=on | The MPP mode is not used. | TiDB ignores the cost estimate and selects the MPP mode. | -For example, if you do not want to use MPP mode, you can execute the following statements: +For example, if you do not want to use the MPP mode, you can execute the following statements: {{< copyable "sql" >}} @@ -280,7 +280,7 @@ set @@session.tidb_allow_mpp=1; set @@session.tidb_enforce_mpp=0; ``` -If you want to use the cost estimation of TiDB optimizer to intelligently choose whether to use MPP mode (by default), you can execute the following statements: +If you want to use the cost estimation of TiDB optimizer to intelligently selects whether to use the MPP mode (by default), you can execute the following statements: {{< copyable "sql" >}} @@ -289,7 +289,7 @@ set @@session.tidb_allow_mpp=1; set @@session.tidb_enforce_mpp=0; ``` -If you want TiDB to ignore the optimizer's cost estimations and force to choose the MPP mode, you can execute the following statements: +If you want TiDB to ignore the optimizer's cost estimations and force to select the MPP mode, you can execute the following statements: {{< copyable "sql" >}} @@ -298,13 +298,13 @@ set @@session.tidb_allow_mpp=1; set @@session.tidb_enforce_mpp=1; ``` -The initial value of the session variable `tidb_enforce_mpp` is equal to the [`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration item value of this tidb-server instance (which is `false` by default). If you want to make several tidb servers only serve analytical quries in a TiDB cluster and to force them to use MPP mode, you can change their [`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration value to `true`. +The initial value of the session variable `tidb_enforce_mpp` is equal to the [`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration item value of this tidb-server instance (which is `false` by default). If you want to make several tidb servers only serve analytical quries in a TiDB cluster and to force them to use the MPP mode, you can change their [`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration value to `true`. > **Note:** > -> When `tidb_enforce_mpp=1` takes effect, TiDB optimizer will ignore the cost estimation to choose MPP mode. However, TiDB will not select MPP mode if other factors block MPP mode, such as no TiFlash replica, the replication of TiFlash replicas is not completed, and statements contain operators or functions that are not supported by MPP mode. +> When `tidb_enforce_mpp=1` takes effect, TiDB optimizer will ignore the cost estimation to select the MPP mode. However, TiDB will not select the MPP mode if other factors block the MPP mode, such as no TiFlash replica, the replication of TiFlash replicas is not completed, and statements contain operators or functions that are not supported by the MPP mode. > -> If TiDB optimizer cannot select MPP mode due to reasons other than cost estimation, when you use the `EXPLAIN` statement to view the execution plan, a warning is returned to explain the reason. For example: +> If TiDB optimizer cannot select the MPP mode due to reasons other than cost estimation, when you use the `EXPLAIN` statement to view the execution plan, a warning is returned to explain the reason. For example: > > {{< copyable "sql" >}} > @@ -323,9 +323,9 @@ The initial value of the session variable `tidb_enforce_mpp` is equal to the [`e > +---------+------+-----------------------------------------------------------------------------+ > ``` -### Algorithm support for MPP mode +### Algorithm support for the MPP mode -MPP mode supports these physical algorithms: Broadcast Hash Join, Shuffled Hash Join, Shuffled Hash Aggregation, Union All, TopN, and Limit. The optimizer automatically determines which algorithm to be used in a query. To check the specific query execution plan, you can execute the `EXPLAIN` statement. If the result of the `EXPLAIN` statement shows ExchangeSender and ExchangeReceiver operators, it indicates that the MPP mode has taken effect. +The MPP mode supports these physical algorithms: Broadcast Hash Join, Shuffled Hash Join, Shuffled Hash Aggregation, Union All, TopN, and Limit. The optimizer automatically determines which algorithm to be used in a query. To check the specific query execution plan, you can execute the `EXPLAIN` statement. If the result of the `EXPLAIN` statement shows ExchangeSender and ExchangeReceiver operators, it indicates that the MPP mode has taken effect. The following statement takes the table structure in the TPC-H test set as an example: @@ -390,4 +390,4 @@ Currently, TiFlash does not support some features. These features might be incom In the example above, `a/b`'s inferred type from the compiling is `Decimal(7,4)` both in TiDB and in TiFlash. Constrained by `Decimal(7,4)`, `a/b`'s returned type should be `0.0000`. In TiDB, `a/b`'s runtime precision is higher than `Decimal(7,4)`, so the original table data is not filtered by the `where a/b` condition. However, in TiFlash, the calculation of `a/b` uses `Decimal(7,4)` as the result type, so the original table data is filtered by the `where a/b` condition. * The MPP mode in TiFlash does not support the following features: - * If the [`new_collations_enabled_on_first_bootstrap`](/tidb-configuration-file.md#new_collations_enabled_on_first_bootstrap) configuration item's value is `true`, the MPP mode does not support the string-type join key or the string column type in the `group by` aggregation. For these two query types, the MPP mode is not chosen by default. + * If the [`new_collations_enabled_on_first_bootstrap`](/tidb-configuration-file.md#new_collations_enabled_on_first_bootstrap) configuration item's value is `true`, the MPP mode does not support the string-type join key or the string column type in the `group by` aggregation. For these two query types, the MPP mode is not selected by default. From 7b6f8f55f9992bf0961c6b24147478a518d82160 Mon Sep 17 00:00:00 2001 From: JoyinQ <56883733+Joyinqin@users.noreply.github.com> Date: Mon, 21 Jun 2021 19:31:41 +0800 Subject: [PATCH 12/17] Apply suggestions from code review Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com> --- system-variables.md | 8 ++++---- tidb-configuration-file.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/system-variables.md b/system-variables.md index 272c87e672cc2..3362c6e9e939e 100644 --- a/system-variables.md +++ b/system-variables.md @@ -205,9 +205,9 @@ mysql> SELECT * FROM t1; - Scope: SESSION | GLOBAL - Default value: `ON` -- This variable controls whether to use the MPP mode of TiFlash to execute queries. You can set the following values, including: - - `0` or `OFF`, which means never use MPP mode. - - `1` or `ON`, which means that the optimizer determines whether to use MPP mode based on the cost estimation (by default). +- This variable controls whether to use the MPP mode of TiFlash to execute queries. The value options are as follows: + - `0` or `OFF`, which means that the MPP mode will not be used. + - `1` or `ON`, which means that the optimizer determines whether to use the MPP mode based on the cost estimation (by default). MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about the MPP mode selection, refer to [Control whether to select the MPP mode](/tiflash/use-tiflash.md#control-whether-to-select-the-mpp-mode). @@ -612,7 +612,7 @@ Query OK, 0 rows affected (0.09 sec) - Scope: SESSION - Default value: `OFF` -- This variable is used to control whether to ignore the optimizer cost estimation and force queries to be executed using TiFlash's MPP mode. You can set the following values: +- Controls whether to ignore the optimizer's cost estimation and to force queries to be executed using TiFlash's MPP mode. The value options are as follows: - `0` or `OFF`, which means the MPP mode is not mandatory (by default). - `1` or `ON`, which means that the cost estimation is ignored and the MPP mode is forced to use. Note that this setting only takes effect when `tidb_allow_mpp=true`. diff --git a/tidb-configuration-file.md b/tidb-configuration-file.md index 1ad603eafec5e..44e562c3c4789 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -440,7 +440,7 @@ Configuration items related to performance. ### `enforce-mpp` -+ Determines whether to ignore the optimizer cost estimation and force TiFlash's MPP mode to execute queries. ++ Determines whether to ignore the optimizer's cost estimation and to force queries to be executed using TiFlash's MPP mode. + Default value: `false` + This configuration item is the initial value of [`tidb_enforce_mpp`](/system-variables.md#tidb_enforce_mpp-new-in-v51). From ea0688990d64c0e345605c0aaeb21d391ecba370 Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Mon, 21 Jun 2021 19:51:34 +0800 Subject: [PATCH 13/17] update suggestions --- system-variables.md | 10 +++++----- tiflash/use-tiflash.md | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/system-variables.md b/system-variables.md index 3362c6e9e939e..dee6a2b185d1a 100644 --- a/system-variables.md +++ b/system-variables.md @@ -205,11 +205,11 @@ mysql> SELECT * FROM t1; - Scope: SESSION | GLOBAL - Default value: `ON` -- This variable controls whether to use the MPP mode of TiFlash to execute queries. The value options are as follows: +- Controls whether to use the MPP mode of TiFlash to execute queries. The value options are as follows: - `0` or `OFF`, which means that the MPP mode will not be used. - `1` or `ON`, which means that the optimizer determines whether to use the MPP mode based on the cost estimation (by default). -MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about the MPP mode selection, refer to [Control whether to select the MPP mode](/tiflash/use-tiflash.md#control-whether-to-select-the-mpp-mode). +MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about the selection of the MPP mode, refer to [Control whether to select the MPP mode](/tiflash/use-tiflash.md#control-whether-to-choose-the-mpp-mode). ### tidb_allow_remove_auto_inc New in v2.1.18 and v3.0.4 @@ -613,10 +613,10 @@ Query OK, 0 rows affected (0.09 sec) - Scope: SESSION - Default value: `OFF` - Controls whether to ignore the optimizer's cost estimation and to force queries to be executed using TiFlash's MPP mode. The value options are as follows: - - `0` or `OFF`, which means the MPP mode is not mandatory (by default). - - `1` or `ON`, which means that the cost estimation is ignored and the MPP mode is forced to use. Note that this setting only takes effect when `tidb_allow_mpp=true`. + - `0` or `OFF`, which means that the MPP mode is not forcibly used (by default). + - `1` or `ON`, which means that the cost estimation is ignored and the MPP mode is forcibly used. Note that this setting only takes effect when `tidb_allow_mpp=true`. -MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about the MPP mode selection, refer to [Control whether to select the MPP mode](/tiflash/use-tiflash.md#control-whether-to-select-the-mpp-mode). +MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about the selection of the MPP mode, refer to [Control whether to select the MPP mode](/tiflash/use-tiflash.md#control-whether-to-select-the-mpp-mode). ### tidb_evolve_plan_baselines New in v4.0 diff --git a/tiflash/use-tiflash.md b/tiflash/use-tiflash.md index 796e73d536515..53e65b134f5e3 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -262,14 +262,14 @@ TiFlash supports using the MPP mode to execute queries, which introduces cross-n ### Control whether to select the MPP mode -`tidb_allow_mpp` controls whether TiDB can select the MPP mode to execute queries. `tidb_enforce_mpp` controls whether the optimizer cost estimate is ignored and the MPP mode of TiFlash is forced to execute queries. +The `tidb_allow_mpp` variable controls whether TiDB can select the MPP mode to execute queries. The `tidb_enforce_mpp` variable controls whether the optimizer's cost estimation is ignored and the MPP mode of TiFlash is forcibly used to execute queries. The results corresponding to all values of these two variables are as follows: | | tidb_allow_mpp=off | tidb_allow_mpp=on (by default) | | ---------------------- | -------------------- | -------------------------------- | | tidb_enforce_mpp=off (by default) | The MPP mode is not used. | The optimizer selects the MPP mode based on cost estimation. (by default)| -| tidb_enforce_mpp=on | The MPP mode is not used. | TiDB ignores the cost estimate and selects the MPP mode. | +| tidb_enforce_mpp=on | The MPP mode is not used. | TiDB ignores the cost estimation and selects the MPP mode. | For example, if you do not want to use the MPP mode, you can execute the following statements: @@ -280,7 +280,7 @@ set @@session.tidb_allow_mpp=1; set @@session.tidb_enforce_mpp=0; ``` -If you want to use the cost estimation of TiDB optimizer to intelligently selects whether to use the MPP mode (by default), you can execute the following statements: +If you want TiDB to use the optimizer's cost estimation to intelligently select whether to use the MPP mode (by default), you can execute the following statements: {{< copyable "sql" >}} @@ -289,7 +289,7 @@ set @@session.tidb_allow_mpp=1; set @@session.tidb_enforce_mpp=0; ``` -If you want TiDB to ignore the optimizer's cost estimations and force to select the MPP mode, you can execute the following statements: +If you want TiDB to ignore the optimizer's cost estimation and to forcibly select the MPP mode, you can execute the following statements: {{< copyable "sql" >}} @@ -298,11 +298,11 @@ set @@session.tidb_allow_mpp=1; set @@session.tidb_enforce_mpp=1; ``` -The initial value of the session variable `tidb_enforce_mpp` is equal to the [`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration item value of this tidb-server instance (which is `false` by default). If you want to make several tidb servers only serve analytical quries in a TiDB cluster and to force them to use the MPP mode, you can change their [`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration value to `true`. +The initial value of the `tidb_enforce_mpp` session variable is equal to the [`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration value of this tidb-server instance (which is `false` by default). If multiple tidb-server instances in a TiDB cluster only perform analytical queries and you want to make sure that the MPP mode is used on these instances, you can change their [`enforce-mpp`](/tidb-configuration-file.md#enforce-mpp) configuration values to `true`. > **Note:** > -> When `tidb_enforce_mpp=1` takes effect, TiDB optimizer will ignore the cost estimation to select the MPP mode. However, TiDB will not select the MPP mode if other factors block the MPP mode, such as no TiFlash replica, the replication of TiFlash replicas is not completed, and statements contain operators or functions that are not supported by the MPP mode. +> When `tidb_enforce_mpp=1` takes effect, the TiDB optimizer will ignore the cost estimation to choose the MPP mode. However, if other factors block the MPP mode, TiDB will not select the MPP mode. These factors include the absence of TiFlash replica, unfinished replication of TiFlash replicas, and statements containing operators or functions that are not supported by the MPP mode. > > If TiDB optimizer cannot select the MPP mode due to reasons other than cost estimation, when you use the `EXPLAIN` statement to view the execution plan, a warning is returned to explain the reason. For example: > From 7e79c67b864b423bbabca3be6c8de42a9b087f98 Mon Sep 17 00:00:00 2001 From: Joyinqin Date: Mon, 21 Jun 2021 20:17:24 +0800 Subject: [PATCH 14/17] Update system-variables.md --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index dee6a2b185d1a..ea564cfba119b 100644 --- a/system-variables.md +++ b/system-variables.md @@ -209,7 +209,7 @@ mysql> SELECT * FROM t1; - `0` or `OFF`, which means that the MPP mode will not be used. - `1` or `ON`, which means that the optimizer determines whether to use the MPP mode based on the cost estimation (by default). -MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about the selection of the MPP mode, refer to [Control whether to select the MPP mode](/tiflash/use-tiflash.md#control-whether-to-choose-the-mpp-mode). +MPP is a distributed computing framework provided by the TiFlash engine, which allows data exchange between nodes and provides high-performance, high-throughput SQL algorithms. For details about the selection of the MPP mode, refer to [Control whether to select the MPP mode](/tiflash/use-tiflash.md#control-whether-to-select-the-mpp-mode). ### tidb_allow_remove_auto_inc New in v2.1.18 and v3.0.4 From 144ccd057af67536df9e026a8af176fefc60b572 Mon Sep 17 00:00:00 2001 From: JoyinQ <56883733+Joyinqin@users.noreply.github.com> Date: Tue, 22 Jun 2021 14:00:40 +0800 Subject: [PATCH 15/17] Apply suggestions from code review Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com> --- system-variables.md | 2 +- tidb-configuration-file.md | 2 +- tiflash/use-tiflash.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/system-variables.md b/system-variables.md index ea564cfba119b..a0e41f63ca6b4 100644 --- a/system-variables.md +++ b/system-variables.md @@ -612,7 +612,7 @@ Query OK, 0 rows affected (0.09 sec) - Scope: SESSION - Default value: `OFF` -- Controls whether to ignore the optimizer's cost estimation and to force queries to be executed using TiFlash's MPP mode. The value options are as follows: +- Controls whether to ignore the optimizer's cost estimation and to forcibly use TiFlash's MPP mode for query execution. The value options are as follows: - `0` or `OFF`, which means that the MPP mode is not forcibly used (by default). - `1` or `ON`, which means that the cost estimation is ignored and the MPP mode is forcibly used. Note that this setting only takes effect when `tidb_allow_mpp=true`. diff --git a/tidb-configuration-file.md b/tidb-configuration-file.md index 44e562c3c4789..3a3f34f74ed34 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -440,7 +440,7 @@ Configuration items related to performance. ### `enforce-mpp` -+ Determines whether to ignore the optimizer's cost estimation and to force queries to be executed using TiFlash's MPP mode. ++ Determines whether to ignore the optimizer's cost estimation and to forcibly use TiFlash's MPP mode for query execution. + Default value: `false` + This configuration item is the initial value of [`tidb_enforce_mpp`](/system-variables.md#tidb_enforce_mpp-new-in-v51). diff --git a/tiflash/use-tiflash.md b/tiflash/use-tiflash.md index 53e65b134f5e3..1cb0dc9db4d34 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -258,7 +258,7 @@ If a query encounters unsupported push-down calculations, TiDB needs to complete ## Use the MPP mode -TiFlash supports using the MPP mode to execute queries, which introduces cross-node data exchange (data shuffle process) into the computation. TiDB automatically determines whether to select the MPP mode using the optimizer. You can change the selection strategy by modifying the values of [`tidb_allow_mpp`](/system-variables.md#tidb_allow_mpp-new-in-v50) and [`tidb_enforce_mpp`](/system-variables.md#tidb_enforce_mpp-new-in-v51). +TiFlash supports using the MPP mode to execute queries, which introduces cross-node data exchange (data shuffle process) into the computation. TiDB automatically determines whether to select the MPP mode using the optimizer's cost estimation. You can change the selection strategy by modifying the values of [`tidb_allow_mpp`](/system-variables.md#tidb_allow_mpp-new-in-v50) and [`tidb_enforce_mpp`](/system-variables.md#tidb_enforce_mpp-new-in-v51). ### Control whether to select the MPP mode From 2d529815679b8f668e5b88d4543721f67907bdd0 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Tue, 22 Jun 2021 16:28:21 +0800 Subject: [PATCH 16/17] Update tiflash/use-tiflash.md --- tiflash/use-tiflash.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiflash/use-tiflash.md b/tiflash/use-tiflash.md index 1cb0dc9db4d34..21979ea554314 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -280,7 +280,7 @@ set @@session.tidb_allow_mpp=1; set @@session.tidb_enforce_mpp=0; ``` -If you want TiDB to use the optimizer's cost estimation to intelligently select whether to use the MPP mode (by default), you can execute the following statements: +If you want TiDB's cost-based optimizer to automatically decide whether to use the MPP mode (by default), you can execute the following statements: {{< copyable "sql" >}} From 5f009932fce5ef386189203c1965f39482f1b952 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Tue, 22 Jun 2021 16:42:49 +0800 Subject: [PATCH 17/17] Update tiflash/use-tiflash.md --- tiflash/use-tiflash.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiflash/use-tiflash.md b/tiflash/use-tiflash.md index 21979ea554314..e8ef201eb05a6 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -304,7 +304,7 @@ The initial value of the `tidb_enforce_mpp` session variable is equal to the [`e > > When `tidb_enforce_mpp=1` takes effect, the TiDB optimizer will ignore the cost estimation to choose the MPP mode. However, if other factors block the MPP mode, TiDB will not select the MPP mode. These factors include the absence of TiFlash replica, unfinished replication of TiFlash replicas, and statements containing operators or functions that are not supported by the MPP mode. > -> If TiDB optimizer cannot select the MPP mode due to reasons other than cost estimation, when you use the `EXPLAIN` statement to view the execution plan, a warning is returned to explain the reason. For example: +> If TiDB optimizer cannot select the MPP mode due to reasons other than cost estimation, when you use the `EXPLAIN` statement to check out the execution plan, a warning is returned to explain the reason. For example: > > {{< copyable "sql" >}} >