diff --git a/correlated-subquery-optimization.md b/correlated-subquery-optimization.md index 1477dfe06f48f..08c753be17775 100644 --- a/correlated-subquery-optimization.md +++ b/correlated-subquery-optimization.md @@ -100,4 +100,4 @@ explain select * from t1 where t1.a < (select sum(t2.a) from t2 where t2.b = t1. +------------------------------------------+-----------+-----------+------------------------+--------------------------------------------------------------------------------------+ ``` -After disabling the subquery decorrelation rule, you can see `range: decided by [eq(test.t2.b, test.t1.b)]` in `operator info` of `IndexRangeScan_25(Build)`. It means that the decorrelation of correlated subquery is not performed and TiDB uses the index range query. +After disabling the subquery decorrelation rule, you can see `range: decided by [eq(test.t2.b, test.t1.b)]` in `operator info` of `IndexRangeScan_42(Build)`. It means that the decorrelation of correlated subquery is not performed and TiDB uses the index range query. diff --git a/explain-subqueries.md b/explain-subqueries.md index 7558e01f67155..5b7c08a4f5154 100644 --- a/explain-subqueries.md +++ b/explain-subqueries.md @@ -67,11 +67,11 @@ EXPLAIN SELECT * FROM t1 WHERE id IN (SELECT t1_id FROM t2); +--------------------------------+----------+-----------+------------------------------+---------------------------------------------------------------------------------------------------------------------------+ ``` -From the query results above, you can see that TiDB uses the index join operation `| IndexJoin_14` to join and transform the subquery. In the execution plan, the execution process is as follows: +From the query results above, you can see that TiDB uses the index join operation `IndexJoin_15` to join and transform the subquery. In the execution plan, the execution process is as follows: -1. The index scanning operator `└─IndexFullScan_31` at the TiKV side reads the values of the `t2.t1_id` column. -2. Some tasks of the `└─StreamAgg_39` operator deduplicate the values of `t1_id` in TiKV. -3. Some tasks of the `├─StreamAgg_49(Build)` operator deduplicate the values of `t1_id` in TiDB. The deduplication is performed by the aggregate function `firstrow(test.t2.t1_id)`. +1. The index scanning operator `└─IndexFullScan_26` at the TiKV side reads the values of the `t2.t1_id` column. +2. Some tasks of the `└─StreamAgg_34` operator deduplicate the values of `t1_id` in TiKV. +3. Some tasks of the `├─StreamAgg_44(Build)` operator deduplicate the values of `t1_id` in TiDB. The deduplication is performed by the aggregate function `firstrow(test.t2.t1_id)`. 4. The operation results are joined with the primary key of the `t1` table. The join condition is `eq(test.t1.id, test.t2.t1_id)`. ## Inner join (unique subquery)