From 3aa215888592345130694b7d63c0d3a4021ffe90 Mon Sep 17 00:00:00 2001 From: Yiding Cui Date: Fri, 9 Sep 2022 15:06:11 +0800 Subject: [PATCH 1/5] system_var, planner: add variable for controlling the algorithm of join reorder --- system-variables.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/system-variables.md b/system-variables.md index f9cbea6c6bb7..7e7d0817d7d2 100644 --- a/system-variables.md +++ b/system-variables.md @@ -2037,6 +2037,15 @@ mysql> desc select count(distinct a) from test.t; select t.* from t, t1 where t.a=t1.aa; ``` +### `tidb_opt_join_reorder_threshold` + +- 作用域: SESSION | GLOBAL +- 是否持久化到集群:是 +- 默认值:`0` +- 范围:`[0, 2147483647]` +- 这个变量用来控制 TIDB Join Reorder 算法的选择 +- 目前对于 OLTP 的查询推荐保持默认值,对于 OLAP 的查询推荐将其设置为 10~15 来获得 AP 场景下更好的连接顺序。 + ### `tidb_opt_limit_push_down_threshold` - 作用域:SESSION | GLOBAL From f4f50d929728f6cdcce3a491df4576fab28fdc4c Mon Sep 17 00:00:00 2001 From: Yiding Cui Date: Fri, 16 Sep 2022 13:35:18 +0800 Subject: [PATCH 2/5] Update system-variables.md Co-authored-by: shichun-0415 <89768198+shichun-0415@users.noreply.github.com> --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index 7e7d0817d7d2..0ac0579e3830 100644 --- a/system-variables.md +++ b/system-variables.md @@ -2037,7 +2037,7 @@ mysql> desc select count(distinct a) from test.t; select t.* from t, t1 where t.a=t1.aa; ``` -### `tidb_opt_join_reorder_threshold` +### `tidb_opt_join_reorder_threshold` 从 v6.3.0 版本开始引入 - 作用域: SESSION | GLOBAL - 是否持久化到集群:是 From abcee44652c3519fca5dbcf3bf1bc8cf7bbd8b05 Mon Sep 17 00:00:00 2001 From: Yiding Cui Date: Fri, 16 Sep 2022 13:35:35 +0800 Subject: [PATCH 3/5] Update system-variables.md Co-authored-by: Grace Cai --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index 0ac0579e3830..bf4cfced893e 100644 --- a/system-variables.md +++ b/system-variables.md @@ -2043,7 +2043,7 @@ mysql> desc select count(distinct a) from test.t; - 是否持久化到集群:是 - 默认值:`0` - 范围:`[0, 2147483647]` -- 这个变量用来控制 TIDB Join Reorder 算法的选择 +- 这个变量用来控制 TiDB Join Reorder 算法的选择。 - 目前对于 OLTP 的查询推荐保持默认值,对于 OLAP 的查询推荐将其设置为 10~15 来获得 AP 场景下更好的连接顺序。 ### `tidb_opt_limit_push_down_threshold` From 979bf0b7a6e324580d8ed3e12090c86012e599de Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Thu, 29 Sep 2022 15:26:51 +0800 Subject: [PATCH 4/5] Update system-variables.md Co-authored-by: Grace Cai --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index bf4cfced893e..576f6a923499 100644 --- a/system-variables.md +++ b/system-variables.md @@ -2037,7 +2037,7 @@ mysql> desc select count(distinct a) from test.t; select t.* from t, t1 where t.a=t1.aa; ``` -### `tidb_opt_join_reorder_threshold` 从 v6.3.0 版本开始引入 +### `tidb_opt_join_reorder_threshold` - 作用域: SESSION | GLOBAL - 是否持久化到集群:是 From fcd0464fa21f723aa212a715d39dae53a1e08c00 Mon Sep 17 00:00:00 2001 From: Yiding Cui Date: Wed, 12 Oct 2022 19:24:17 +0800 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com> --- system-variables.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system-variables.md b/system-variables.md index 576f6a923499..15d7a4355df7 100644 --- a/system-variables.md +++ b/system-variables.md @@ -2043,8 +2043,8 @@ mysql> desc select count(distinct a) from test.t; - 是否持久化到集群:是 - 默认值:`0` - 范围:`[0, 2147483647]` -- 这个变量用来控制 TiDB Join Reorder 算法的选择。 -- 目前对于 OLTP 的查询推荐保持默认值,对于 OLAP 的查询推荐将其设置为 10~15 来获得 AP 场景下更好的连接顺序。 +- 这个变量用来控制 TiDB Join Reorder 算法的选择。当参与 Join Reorder 的节点个数大于该阈值时,TiDB 选择贪心算法,小于该阈值时 TiDB 选择动态规划 (dynamic programming) 算法。 +- 目前对于 OLTP 的查询,推荐保持默认值。对于 OLAP 的查询,推荐将变量值设为 10~15 来获得 AP 场景下更好的连接顺序。 ### `tidb_opt_limit_push_down_threshold`