Skip to content

Commit

Permalink
Do not merge until v6.5.6: sysvar: add system variable `tidb_opt_enab…
Browse files Browse the repository at this point in the history
…le_hash_join` (#15105) (#15265) (#15586)
  • Loading branch information
ti-chi-bot authored Dec 7, 2023
1 parent 4adcbfa commit 2dff627
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
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

0 comments on commit 2dff627

Please sign in to comment.