From 91ceb3980abad8e3610599faa30a96ff3a44f782 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 d58b285ef9c5d..ddca8ff630c18 100644 --- a/system-variables.md +++ b/system-variables.md @@ -206,8 +206,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 @@ -596,6 +599,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 dda3d8d1e8e9f..58328717f0382 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -439,6 +439,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 a701a70abfdd2..e0eae5c583e27 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -259,12 +259,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 00d79953d42dba9d4987f2bf66e77fc821cf7aa1 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 58328717f0382..bbfb57bdef04b 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -443,7 +443,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 e0eae5c583e27..65b3eb51bcfac 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -259,7 +259,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 f87615d75b06eb30e8527e84bd0439a5ef41c116 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 ddca8ff630c18..2aff877dc21f9 100644 --- a/system-variables.md +++ b/system-variables.md @@ -208,7 +208,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). @@ -605,7 +605,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 bbfb57bdef04b..06474ed10906e 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -441,7 +441,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 65b3eb51bcfac..4a2e3052fb909 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -259,20 +259,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" >}} @@ -281,11 +281,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 4572fbf5799d439f4b02ca5f969ddc749debca9b 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 4a2e3052fb909..30f11a782bdd0 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -281,7 +281,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 321226f62c46d8361495b30c052e15b72eed6492 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 2aff877dc21f9..5988d3ddf8879 100644 --- a/system-variables.md +++ b/system-variables.md @@ -603,7 +603,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 06474ed10906e..a6464149b24b8 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -441,7 +441,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 30f11a782bdd0..b9a62df334943 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -272,7 +272,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" >}} @@ -281,7 +281,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" >}} @@ -290,7 +290,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" >}} @@ -299,7 +299,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 b556a79c3dae2fb3a85e44ead92732b9da1d4615 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 5988d3ddf8879..0166eae18b19d 100644 --- a/system-variables.md +++ b/system-variables.md @@ -605,7 +605,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 b9a62df334943..ff5f5b3fa110c 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -281,7 +281,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" >}} @@ -303,9 +303,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 9683b69dfa144544d3df003f751d422fa886732c 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 ff5f5b3fa110c..f0fed5e85efaa 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -303,7 +303,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 1783e505a19ee2c6502901de319193c0b1f3ddbc 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 f0fed5e85efaa..a284771ab4b67 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -299,7 +299,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 c916055183f6bd08bfc706fd541152670bf57e29 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 0166eae18b19d..9337855ddc4f8 100644 --- a/system-variables.md +++ b/system-variables.md @@ -604,7 +604,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 38e7ffd3a57025e6dbf7be6feafe7a53c57c0598 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 a284771ab4b67..31abccfa2b275 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -303,7 +303,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 5d2d2e5070e125d50f2a9edf9e60e1a5c7cc5cd8 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 728bddb928bb2..5a8858265f3b1 100644 --- a/system-variables.md +++ b/system-variables.md @@ -210,7 +210,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 @@ -614,10 +614,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 31abccfa2b275..68400e39e12a7 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -193,7 +193,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 @@ -259,20 +259,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" >}} @@ -281,7 +281,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" >}} @@ -290,7 +290,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" >}} @@ -299,13 +299,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" >}} > @@ -324,9 +324,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: @@ -391,4 +391,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 389b45c0836aa50d0b5ae28a9191dc3b44920317 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 5a8858265f3b1..1a6d8a4e5c347 100644 --- a/system-variables.md +++ b/system-variables.md @@ -206,9 +206,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). @@ -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: +- 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 a6464149b24b8..cc9d90a680efd 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -441,7 +441,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 df3a1110bd46a3241e96423686fca562845c6cb6 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 1a6d8a4e5c347..40aec594c69f2 100644 --- a/system-variables.md +++ b/system-variables.md @@ -206,11 +206,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 @@ -614,10 +614,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 68400e39e12a7..3ea11b32c14bc 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -263,14 +263,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: @@ -281,7 +281,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" >}} @@ -290,7 +290,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" >}} @@ -299,11 +299,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 b5d633c4a0f051780b4e2161e8ade2056deb9567 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 40aec594c69f2..6469a6849f232 100644 --- a/system-variables.md +++ b/system-variables.md @@ -210,7 +210,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 a9eb73841722a64f1b8567ecdb6bda4b2efefb94 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 6469a6849f232..eabede51b3cbf 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` -- 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 cc9d90a680efd..186c4e638b7b1 100644 --- a/tidb-configuration-file.md +++ b/tidb-configuration-file.md @@ -441,7 +441,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 3ea11b32c14bc..36002696ebc22 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -259,7 +259,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 1ad21c866ea98dcf15141a28af91ac173b8d7504 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 36002696ebc22..7d588e419c3cc 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -281,7 +281,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 559bf35da9d706a41dde2edf4ae3c1c8e854263f 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 7d588e419c3cc..d7adc9cf38535 100644 --- a/tiflash/use-tiflash.md +++ b/tiflash/use-tiflash.md @@ -305,7 +305,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" >}} >