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

Do not merge until v6.5.6: sysvar: add system variable tidb_opt_enable_hash_join (#15105) (#15265) #15586

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 11 additions & 1 deletion optimizer-hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -935,4 +935,14 @@ CREATE TABLE t1 (a INT);
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
```
```

- 系统变量 [`tidb_opt_enable_hash_join`](/system-variables.md#tidb_opt_enable_hash_join-从-v656-版本开始引入) 设置为 `OFF`,而且其他 Join 方式也都被排除了。

```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
```
9 changes: 9 additions & 0 deletions system-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -2464,6 +2464,15 @@ mysql> desc select count(distinct a) from test.t;
- 默认值:`ON`
- 这个变量用来控制优化器是否开启交叉估算。

### `tidb_opt_enable_hash_join` <span class="version-mark">从 v6.5.6 版本开始引入</span>

- 作用域:SESSION | GLOBAL
- 是否持久化到集群:是
- 类型:布尔型
- 默认值:`ON`
- 控制优化器是否会选择表的哈希连接。默认打开 (`ON`)。设置为 `OFF` 时,优化器在生成执行计划时会避免选择表的哈希连接,除非没有其他连接方式可用。
- 如果同时使用了 `tidb_opt_enable_hash_join` 和 `HASH_JOIN` Hint,则 `HASH_JOIN` Hint 优先级更高。即使 `tidb_opt_enable_hash_join` 被设置为 `OFF`,如果在查询中指定了 `HASH_JOIN` Hint,TiDB 优化器仍然会强制执行哈希连接计划。

### `tidb_opt_force_inline_cte` <span class="version-mark">从 v6.3.0 版本开始引入</span>

- 作用域:SESSION | GLOBAL
Expand Down