From 2d8462135945338839ef0e97baddc55cfa297c49 Mon Sep 17 00:00:00 2001 From: houfaxin Date: Tue, 24 Feb 2026 10:37:53 +0800 Subject: [PATCH 1/2] Update system-variables.md --- system-variables.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/system-variables.md b/system-variables.md index 79af0db79a694..e2dd634c327de 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4545,6 +4545,17 @@ mysql> desc select count(distinct a) from test.t; - This variable is used to control the selection of the TiDB Join Reorder algorithm. When the number of nodes participating in Join Reorder is greater than this threshold, TiDB selects the greedy algorithm, and when it is less than this threshold, TiDB selects the dynamic programming algorithm. - Currently, for OLTP queries, it is recommended to keep the default value. For OLAP queries, it is recommended to set the variable value to 10~15 to get better connection orders in OLAP scenarios. +### tidb_opt_join_reorder_through_sel New in v8.5.6 and v9.0.0 + +- Scope: SESSION | GLOBAL +- Persists to cluster: Yes +- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): Yes +- Type: Boolean +- Default value: `OFF` +- This variable improves join reorder optimization for certain multi-table JOIN queries. When set to `ON`, the optimizer evaluates `Selection` conditions that appear between consecutive JOIN operators together with join order candidates, provided that safety conditions are met. During join tree reconstruction, the optimizer pushes these conditions to more appropriate positions whenever possible, allowing more tables to participate in join order optimization. +- Enabling this variable changes execution plans. If you observe performance regression or plan instability after enabling it, set the variable to `OFF`. +- For filters that are non-deterministic or have side effects (for example, `rand()`), the optimizer skips this transformation even when the variable is enabled. This behavior preserves the original expression evaluation semantics. + ### tidb_opt_limit_push_down_threshold - Scope: SESSION | GLOBAL From 5f48abd0ab4778b9425b510f1d1029fbe135c744 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Tue, 24 Feb 2026 13:29:47 +0800 Subject: [PATCH 2/2] Update system-variables.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@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 e2dd634c327de..2c81307b9fe31 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4552,7 +4552,7 @@ mysql> desc select count(distinct a) from test.t; - Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): Yes - Type: Boolean - Default value: `OFF` -- This variable improves join reorder optimization for certain multi-table JOIN queries. When set to `ON`, the optimizer evaluates `Selection` conditions that appear between consecutive JOIN operators together with join order candidates, provided that safety conditions are met. During join tree reconstruction, the optimizer pushes these conditions to more appropriate positions whenever possible, allowing more tables to participate in join order optimization. +- This variable improves join reorder optimization for certain multi-table join queries. If you set it to `ON` and safety conditions are met, the optimizer evaluates `Selection` conditions that appear between consecutive join operators together with join order candidates. During join tree reconstruction, the optimizer pushes these conditions to more appropriate positions whenever possible, allowing more tables to participate in join order optimization. - Enabling this variable changes execution plans. If you observe performance regression or plan instability after enabling it, set the variable to `OFF`. - For filters that are non-deterministic or have side effects (for example, `rand()`), the optimizer skips this transformation even when the variable is enabled. This behavior preserves the original expression evaluation semantics.