From 1bbc0a503318901809c19a620c721004a49bd098 Mon Sep 17 00:00:00 2001 From: tpp Date: Mon, 20 Oct 2025 16:39:13 -0700 Subject: [PATCH 1/6] planner: Add subquery variables --- system-variables.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/system-variables.md b/system-variables.md index 27d4fec816dbc..86a806534d7f1 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4104,6 +4104,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 77e073cc42def58d09ebc09dfd4be610eaf2d3be 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/6] 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 86a806534d7f1..3d2c8cc7b826b 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4104,7 +4104,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 50a4c92eea0053b7c63cf1e91196418360ad97b5 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/6] 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 3d2c8cc7b826b..744df61b3fa78 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4111,7 +4111,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 96987af756befd547e0978daede3d48006ca32ca 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/6] 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 744df61b3fa78..afb6c42434b44 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4113,7 +4113,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 e23d2d8c45264ff97298faf1da7fbb4a12dc7883 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/6] 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 afb6c42434b44..c92cbf670ce53 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4120,7 +4120,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 40f23c339de8e96db678024828a4bfbb632d9529 Mon Sep 17 00:00:00 2001 From: Aolin Date: Tue, 4 Nov 2025 16:17:37 +0800 Subject: [PATCH 6/6] 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 c92cbf670ce53..0c0184e4794e5 100644 --- a/system-variables.md +++ b/system-variables.md @@ -4111,7 +4111,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 @@ -4120,7 +4120,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