Skip to content
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
2 changes: 1 addition & 1 deletion correlated-subquery-optimization.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ explain select * from t1 where t1.a < (select sum(t2.a) from t2 where t2.b = t1.
+------------------------------------------+-----------+-----------+------------------------+--------------------------------------------------------------------------------------+
```

在执行了关闭关联规则的语句后,可以在 `IndexRangeScan_25(Build)` 的 `operator info` 中看到 `range: decided by [eq(test.t2.b, test.t1.b)]`。这部分信息就是关联依赖未被解除时,TiDB 使用关联条件进行索引范围查询的显示结果。
在执行了关闭关联规则的语句后,可以在 `IndexRangeScan_42(Build)` 的 `operator info` 中看到 `range: decided by [eq(test.t2.b, test.t1.b)]`。这部分信息就是关联依赖未被解除时,TiDB 使用关联条件进行索引范围查询的显示结果。
2 changes: 1 addition & 1 deletion explain-subqueries.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ EXPLAIN SELECT * FROM t1 WHERE id IN (SELECT t1_id FROM t2);

```

由上述查询结果可知,TiDB 通过索引连接操作 `| IndexJoin_14` 将子查询做了连接转化。该执行计划首先在 TiKV 侧通过索引扫描算子 `└─IndexFullScan_31` 读取 `t2.t1_id` 列的值,然后由 `└─StreamAgg_39` 算子的部分任务在 TiKV 中对 `t1_id` 值进行去重,然后采用 `├─StreamAgg_49(Build)` 算子的部分任务在 TiDB 中对 `t1_id` 值再次进行去重,去重操作由聚合函数 `firstrow(test.t2.t1_id)` 执行;之后将操作结果与 `t1` 表的主键相连接,连接条件是 `eq(test.t1.id, test.t2.t1_id)`。
由上述查询结果可知,TiDB 通过索引连接操作 `IndexJoin_15` 将子查询做了连接转化。该执行计划首先在 TiKV 侧通过索引扫描算子 `└─IndexFullScan_26` 读取 `t2.t1_id` 列的值,然后由 `└─StreamAgg_34` 算子的部分任务在 TiKV 中对 `t1_id` 值进行去重,然后采用 `├─StreamAgg_44(Build)` 算子的部分任务在 TiDB 中对 `t1_id` 值再次进行去重,去重操作由聚合函数 `firstrow(test.t2.t1_id)` 执行;之后将操作结果与 `t1` 表的主键相连接,连接条件是 `eq(test.t1.id, test.t2.t1_id)`。

## Inner join(有 `UNIQUE` 约束的子查询)

Expand Down