From 8d676ef27f2097f111329ddaca04935cb480023c Mon Sep 17 00:00:00 2001 From: tpp Date: Mon, 20 Oct 2025 16:39:13 -0700 Subject: [PATCH 1/7] planner: Add subquery variables --- system-variables.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/system-variables.md b/system-variables.md index 6ad5c710e3ace..23cd0b667ac2a 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4297,6 +4297,24 @@ mysql> desc select count(distinct a) from test.t; - Default value: `OFF` - This variable controls whether to enable the [Cross-database binding](/sql-plan-management.md#cross-database-binding) feature. +### tidb_opt_enable_no_decorrelate_in_select New in v8.5.4 + +- 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 controls whether to apply the hint [`NO_DECORRELATE`](/optimizer-hints.md#no_decorrelate) at the session/global level for all queries with a subquery in the select list. + +### tidb_opt_enable_semi_join_rewrite New in v8.5.4 + +- Scope: SESSION | GLOBAL +- Persists to cluster: Yes +- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No +- Type: Boolean +- Default value: `OFF` +- This variable controls whether to apply the hint [`SEMI_JOIN_REWRITE`](/optimizer-hints.md#semi_join_rewrite) at the session/global level for all queries that contain subqueries. + ### tidb_opt_fix_control New in v6.5.3 and v7.1.0 From a1559efe661d21953b06f9bee7124e3a44b2a171 Mon Sep 17 00:00:00 2001 From: tpp <146148086+terry1purcell@users.noreply.github.com> Date: Mon, 3 Nov 2025 19:24:39 -0800 Subject: [PATCH 2/7] Apply suggestion from @Oreoxmt Co-authored-by: Aolin --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index 23cd0b667ac2a..e15edc4e60a77 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4297,7 +4297,7 @@ mysql> desc select count(distinct a) from test.t; - Default value: `OFF` - This variable controls whether to enable the [Cross-database binding](/sql-plan-management.md#cross-database-binding) feature. -### tidb_opt_enable_no_decorrelate_in_select New in v8.5.4 +### tidb_opt_enable_no_decorrelate_in_select New in v8.5.4 and v9.0.0 - Scope: SESSION | GLOBAL - Persists to cluster: Yes From cbe932a95cad7c72470cd74a74091c1ed591a3c9 Mon Sep 17 00:00:00 2001 From: tpp <146148086+terry1purcell@users.noreply.github.com> Date: Mon, 3 Nov 2025 19:25:02 -0800 Subject: [PATCH 3/7] Apply suggestion from @Oreoxmt Co-authored-by: Aolin --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index e15edc4e60a77..a93055b2f4666 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4304,7 +4304,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 controls whether to apply the hint [`NO_DECORRELATE`](/optimizer-hints.md#no_decorrelate) at the session/global level for all queries with a subquery in the select list. +- This variable controls whether the optimizer applies the [`NO_DECORRELATE()`](/optimizer-hints.md#no_decorrelate) hint at the session or global level for all queries that contain a subquery in the `SELECT` list. ### tidb_opt_enable_semi_join_rewrite New in v8.5.4 From 5ccb23f10df087b4257711b0b40505f0c65cb807 Mon Sep 17 00:00:00 2001 From: tpp <146148086+terry1purcell@users.noreply.github.com> Date: Mon, 3 Nov 2025 19:25:10 -0800 Subject: [PATCH 4/7] Apply suggestion from @Oreoxmt Co-authored-by: Aolin --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index a93055b2f4666..1b96b3273474a 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4306,7 +4306,7 @@ mysql> desc select count(distinct a) from test.t; - Default value: `OFF` - This variable controls whether the optimizer applies the [`NO_DECORRELATE()`](/optimizer-hints.md#no_decorrelate) hint at the session or global level for all queries that contain a subquery in the `SELECT` list. -### tidb_opt_enable_semi_join_rewrite New in v8.5.4 +### tidb_opt_enable_semi_join_rewrite New in v8.5.4 and v9.0.0 - Scope: SESSION | GLOBAL - Persists to cluster: Yes From 83b9f14df998324377304e2faa564ffc985cc883 Mon Sep 17 00:00:00 2001 From: tpp <146148086+terry1purcell@users.noreply.github.com> Date: Mon, 3 Nov 2025 19:25:17 -0800 Subject: [PATCH 5/7] Apply suggestion from @Oreoxmt Co-authored-by: Aolin --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index 1b96b3273474a..8bd85cfa8a3d7 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4313,7 +4313,7 @@ mysql> desc select count(distinct a) from test.t; - Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No - Type: Boolean - Default value: `OFF` -- This variable controls whether to apply the hint [`SEMI_JOIN_REWRITE`](/optimizer-hints.md#semi_join_rewrite) at the session/global level for all queries that contain subqueries. +- This variable controls whether the optimizer applies the [`SEMI_JOIN_REWRITE()`](/optimizer-hints.md#semi_join_rewrite) hint at the session or global level for all queries that contain subqueries. ### tidb_opt_fix_control New in v6.5.3 and v7.1.0 From 97251647462f7d890d6a67416e6f7fb5b7d50c7e Mon Sep 17 00:00:00 2001 From: Aolin Date: Tue, 4 Nov 2025 16:17:37 +0800 Subject: [PATCH 6/7] Apply suggestions from code review Co-authored-by: Grace Cai --- system-variables.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system-variables.md b/system-variables.md index 8bd85cfa8a3d7..eb3f21c3c0f0f 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4304,7 +4304,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 controls whether the optimizer applies the [`NO_DECORRELATE()`](/optimizer-hints.md#no_decorrelate) hint at the session or global level for all queries that contain a subquery in the `SELECT` list. +- This variable controls whether the optimizer applies the [`NO_DECORRELATE()`](/optimizer-hints.md#no_decorrelate) hint for all queries that contain a subquery in the `SELECT` list. ### tidb_opt_enable_semi_join_rewrite New in v8.5.4 and v9.0.0 @@ -4313,7 +4313,7 @@ mysql> desc select count(distinct a) from test.t; - Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No - Type: Boolean - Default value: `OFF` -- This variable controls whether the optimizer applies the [`SEMI_JOIN_REWRITE()`](/optimizer-hints.md#semi_join_rewrite) hint at the session or global level for all queries that contain subqueries. +- This variable controls whether the optimizer applies the [`SEMI_JOIN_REWRITE()`](/optimizer-hints.md#semi_join_rewrite) hint for all queries that contain subqueries. ### tidb_opt_fix_control New in v6.5.3 and v7.1.0 From 104bdc40c5c5ecdbcaebae1cacd2931c2f46710b Mon Sep 17 00:00:00 2001 From: Aolin Date: Mon, 10 Nov 2025 14:32:29 +0800 Subject: [PATCH 7/7] Apply suggestions from code review --- system-variables.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system-variables.md b/system-variables.md index eb3f21c3c0f0f..ace88616231e0 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4297,7 +4297,7 @@ mysql> desc select count(distinct a) from test.t; - Default value: `OFF` - This variable controls whether to enable the [Cross-database binding](/sql-plan-management.md#cross-database-binding) feature. -### tidb_opt_enable_no_decorrelate_in_select New in v8.5.4 and v9.0.0 +### tidb_opt_enable_no_decorrelate_in_select New in v8.5.4 - Scope: SESSION | GLOBAL - Persists to cluster: Yes @@ -4306,7 +4306,7 @@ mysql> desc select count(distinct a) from test.t; - Default value: `OFF` - This variable controls whether the optimizer applies the [`NO_DECORRELATE()`](/optimizer-hints.md#no_decorrelate) hint for all queries that contain a subquery in the `SELECT` list. -### tidb_opt_enable_semi_join_rewrite New in v8.5.4 and v9.0.0 +### tidb_opt_enable_semi_join_rewrite New in v8.5.4 - Scope: SESSION | GLOBAL - Persists to cluster: Yes