Skip to content

Commit fbcf8c6

Browse files
authored
doc: correct subquery optimization examples for clarity (#19825) (#19829)
1 parent 2f3198e commit fbcf8c6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

subquery-optimization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ summary: 了解子查询相关的优化。
2424
对于这种情况,可以将 `ALL` 或者 `ANY``MAX` 以及 `MIN` 来代替。不过由于在表为空时,`MAX(EXPR)` 以及 `MIN(EXPR)` 的结果会为 `NULL`,其表现形式和 `EXPR` 是有 `NULL` 值的结果一样。以及外部表达式结果为 `NULL` 时也会影响表达式的最终结果,因此这里完整的改写会是如下的形式:
2525

2626
- `t.id < all(select s.id from s)` 会被改写为 `t.id < min(s.id) and if(sum(s.id is null) != 0, null, true)`
27-
- `t.id < any (select s.id from s)` 会被改写为 `t.id < max(s.id) or if(sum(s.id is null) != 0, null, false)`
27+
- `t.id > any (select s.id from s)` 会被改写为 `t.id > max(s.id) or if(sum(s.id is null) != 0, null, false)`
2828

2929
## `... != ANY (SELECT ... FROM ...)`
3030

0 commit comments

Comments
 (0)