Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sysvar: add system variable tidb_opt_enable_hash_join #14905

Merged
merged 9 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions optimizer-hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -989,3 +989,13 @@ CREATE TABLE t2 (a INT);
EXPLAIN SELECT /*+ NO_HASH_JOIN(t1), NO_MERGE_JOIN(t1) */ * FROM t1, t2 WHERE t1.a=t2.a;
ERROR 1815 (HY000): Internal : Can't find a proper physical plan for this query
```

- The system variable [`tidb_opt_enable_hash_join`](/system-variables.md#tidb_opt_enable_hash_join-new-in-v740) is set to `off`, and all other join types are also excluded.
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

```sql
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a INT);
set tidb_opt_enable_hash_join=off;
EXPLAIN SELECT /*+ NO_MERGE_JOIN(t1) */ * FROM t1, t2 WHERE t1.a=t2.a;
ERROR 1815 (HY000): Internal : Can't find a proper physical plan for this query
```
10 changes: 10 additions & 0 deletions system-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -3517,6 +3517,16 @@ mysql> desc select count(distinct a) from test.t;
- Default value: `ON`
- This variable is used to control whether the optimizer estimates the number of rows based on column order correlation

### `tidb_opt_enable_hash_join` <span class="version-mark">New in v7.4.0</span>

- Scope: SESSION | GLOBAL
- Persists to cluster: Yes
coderplay marked this conversation as resolved.
Show resolved Hide resolved
- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No
- Type: Boolean
- Default value: `ON`
- This variable is used to control whether the optimizer will select hash joins for tables. The value is `ON` by default. If it is set to `OFF`, the optimizer ignores hash join when generating execution plans.
hfxsd marked this conversation as resolved.
Show resolved Hide resolved
- The `HASH_JOIN` hint takes precedence even if `tidb_opt_enable_hash_join` is set to `off`. If a `HASH_JOIN` hint is specified in a query, the TiDB optimizer will still enforce a hash join plan.

### `tidb_opt_enable_non_eval_scalar_subquery` <span class="version-mark">New in v7.3.0</span>

- Scope: SESSION | GLOBAL
Expand Down
Loading