Skip to content

Commit

Permalink
fix a typo in subquery-optimization.md (#18784) (#18787)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Oct 11, 2024
1 parent 9e8e5ae commit b5458e5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion subquery-optimization.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ explain select * from t1 where t1.a in (select t2.a from t2);
+------------------------------+---------+-----------+------------------------+----------------------------------------------------------------------------+
```

这个改写会在 `IN` 子查询相对较小,而外部查询相对较大时产生更好的执行性能。因为不经过改写的情况下,我们无法使用以 t2 为驱动表的 `index join`。同时这里的弊端便是,当改写删成的聚合无法被自动消去且 `t2` 表比较大时,反而会影响查询的性能。目前 TiDB 中使用 [tidb\_opt\_insubq\_to\_join\_and\_agg](/system-variables.md#tidb_opt_insubq_to_join_and_agg) 变量来控制这个优化的打开与否。当遇到不合适这个优化的情况可以手动关闭。
这个改写会在 `IN` 子查询相对较小,而外部查询相对较大时产生更好的执行性能。因为不经过改写的情况下,我们无法使用以 t2 为驱动表的 `index join`。同时这里的弊端便是,当改写生成的聚合无法被自动消去且 `t2` 表比较大时,反而会影响查询的性能。目前 TiDB 中使用 [tidb\_opt\_insubq\_to\_join\_and\_agg](/system-variables.md#tidb_opt_insubq_to_join_and_agg) 变量来控制这个优化的打开与否。当遇到不合适这个优化的情况可以手动关闭。

## `EXISTS` 子查询以及 `... >/>=/</<=/=/!= (SELECT ... FROM ...)`

Expand Down

0 comments on commit b5458e5

Please sign in to comment.