Skip to content

Commit 6895032

Browse files
TomShawnOreoxmt
andcommitted
Apply suggestions from code review
Co-authored-by: Aolin <aolin.zhang@pingcap.com>
1 parent 3597834 commit 6895032

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

optimizer-hints.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,19 @@ select /*+ HASH_JOIN(t1, t2) */ * from t1, t2 where t1.id = t2.id;
135135
136136
### SEMI_JOIN_REWRITE()
137137

138-
The `SEMI_JOIN_REWRITE()` hint tells the optimizer to rewrite the semi join query to an ordinary join query. Currently, this hint only works for `EXISTS` subqueries.
138+
The `SEMI_JOIN_REWRITE()` hint tells the optimizer to rewrite the semi-join query to an ordinary join query. Currently, this hint only works for `EXISTS` subqueries.
139139

140-
If this hint is not used to rewrite the query, when the hash join is selected in the execution plan, the semi join query can only use the subquery to build a hash table. In this case, when the result set of the subquery is bigger than that of the outer query, the execution speed might be slower than expected.
140+
If this hint is not used to rewrite the query, when the hash join is selected in the execution plan, the semi-join query can only use the subquery to build a hash table. In this case, when the result of the subquery is bigger than that of the outer query, the execution speed might be slower than expected.
141141

142-
Similarly, when the index join is selected in the execution plan, the semi join query can only use the outer query as the driving table. In this case, when the result set of the subquery is smaller than that of the outer query, the execution speed might be slower than expected.
142+
Similarly, when the index join is selected in the execution plan, the semi-join query can only use the outer query as the driving table. In this case, when the result of the subquery is smaller than that of the outer query, the execution speed might be slower than expected.
143143

144144
When `SEMI_JOIN_REWRITE()` is used to rewrite the query, the optimizer can extend the selection range to select a better execution plan.
145145

146146
{{< copyable "sql" >}}
147147

148148
```sql
149149
-- Does not use SEMI_JOIN_REWRITE() to rewrite the query.
150-
EXPLAIN SELECT * FROM t WHERE EXISTS (SELECT 1 from t1 where t1.a=t.a);
150+
EXPLAIN SELECT * FROM t WHERE EXISTS (SELECT 1 FROM t1 WHERE t1.a = t.a);
151151
```
152152

153153
```sql
@@ -166,7 +166,7 @@ EXPLAIN SELECT * FROM t WHERE EXISTS (SELECT 1 from t1 where t1.a=t.a);
166166

167167
```sql
168168
-- Uses SEMI_JOIN_REWRITE() to rewrite the query.
169-
EXPLAIN SELECT * FROM t WHERE EXISTS (SELECT /*+ SEMI_JOIN_REWRITE() */ 1 from t1 where t1.a=t.a);
169+
EXPLAIN SELECT * FROM t WHERE EXISTS (SELECT /*+ SEMI_JOIN_REWRITE() */ 1 FROM t1 WHERE t1.a = t.a);
170170
```
171171

172172
```sql

subquery-optimization.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ explain select * from t where exists (select * from t2);
8989

9090
In the preceding optimization, the optimizer automatically optimizes the statement execution. In addition, you can also add the [`SEMI_JOIN_REWRITE`](/optimizer-hints.md#semi_join_rewrite) hint to further rewrite the statement.
9191

92-
If this hint is not used to rewrite the query, when the hash join is selected in the execution plan, the semi join query can only use the subquery to build a hash table. In this case, when the result set of the subquery is bigger than that of the outer query, the execution speed might be slower than expected.
92+
If this hint is not used to rewrite the query, when the hash join is selected in the execution plan, the semi-join query can only use the subquery to build a hash table. In this case, when the result of the subquery is bigger than that of the outer query, the execution speed might be slower than expected.
9393

94-
Similarly, when the index join is selected in the execution plan, the semi join query can only use the outer query as the driving table. In this case, when the result set of the subquery is smaller than that of the outer query, the execution speed might be slower than expected.
94+
Similarly, when the index join is selected in the execution plan, the semi-join query can only use the outer query as the driving table. In this case, when the result of the subquery is smaller than that of the outer query, the execution speed might be slower than expected.
9595

9696
When `SEMI_JOIN_REWRITE()` is used to rewrite the query, the optimizer can extend the selection range to select a better execution plan.

0 commit comments

Comments
 (0)