Skip to content

Commit 45da7ba

Browse files
*: update the row count display of probe side of IndexJoin and Apply (pingcap#10864)
1 parent b4faf58 commit 45da7ba

File tree

8 files changed

+246
-181
lines changed

8 files changed

+246
-181
lines changed

correlated-subquery-optimization.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,20 @@ explain select * from t1 where t1.a < (select /*+ NO_DECORRELATE() */ sum(t2.a)
5757
```
5858

5959
```sql
60-
+----------------------------------------+----------+-----------+------------------------+--------------------------------------------------------------------------------------+
61-
| id | estRows | task | access object | operator info |
62-
+----------------------------------------+----------+-----------+------------------------+--------------------------------------------------------------------------------------+
63-
| Projection_10 | 10000.00 | root | | test.t1.a, test.t1.b |
64-
| └─Apply_12 | 10000.00 | root | | CARTESIAN inner join, other cond:lt(cast(test.t1.a, decimal(10,0) BINARY), Column#7) |
65-
| ├─TableReader_14(Build) | 10000.00 | root | | data:TableFullScan_13 |
66-
| │ └─TableFullScan_13 | 10000.00 | cop[tikv] | table:t1 | keep order:false, stats:pseudo |
67-
| └─MaxOneRow_15(Probe) | 1.00 | root | | |
68-
| └─HashAgg_27 | 1.00 | root | | funcs:sum(Column#10)->Column#7 |
69-
| └─IndexLookUp_28 | 1.00 | root | | |
70-
| ├─IndexRangeScan_25(Build) | 10.00 | cop[tikv] | table:t2, index:idx(b) | range: decided by [eq(test.t2.b, test.t1.b)], keep order:false, stats:pseudo |
71-
| └─HashAgg_17(Probe) | 1.00 | cop[tikv] | | funcs:sum(test.t2.a)->Column#10 |
72-
| └─TableRowIDScan_26 | 10.00 | cop[tikv] | table:t2 | keep order:false, stats:pseudo |
73-
+----------------------------------------+----------+-----------+------------------------+--------------------------------------------------------------------------------------+
60+
+------------------------------------------+-----------+-----------+------------------------+--------------------------------------------------------------------------------------+
61+
| id | estRows | task | access object | operator info |
62+
+------------------------------------------+-----------+-----------+------------------------+--------------------------------------------------------------------------------------+
63+
| Projection_10 | 10000.00 | root | | test.t1.a, test.t1.b |
64+
| └─Apply_12 | 10000.00 | root | | CARTESIAN inner join, other cond:lt(cast(test.t1.a, decimal(10,0) BINARY), Column#7) |
65+
| ├─TableReader_14(Build) | 10000.00 | root | | data:TableFullScan_13 |
66+
| │ └─TableFullScan_13 | 10000.00 | cop[tikv] | table:t1 | keep order:false, stats:pseudo |
67+
| └─MaxOneRow_15(Probe) | 10000.00 | root | | |
68+
| └─StreamAgg_20 | 10000.00 | root | | funcs:sum(Column#14)->Column#7 |
69+
| └─Projection_45 | 100000.00 | root | | cast(test.t2.a, decimal(10,0) BINARY)->Column#14 |
70+
| └─IndexLookUp_44 | 100000.00 | root | | |
71+
| ├─IndexRangeScan_42(Build) | 100000.00 | cop[tikv] | table:t2, index:idx(b) | range: decided by [eq(test.t2.b, test.t1.b)], keep order:false, stats:pseudo |
72+
| └─TableRowIDScan_43(Probe) | 100000.00 | cop[tikv] | table:t2 | keep order:false, stats:pseudo |
73+
+------------------------------------------+-----------+-----------+------------------------+--------------------------------------------------------------------------------------+
7474
```
7575

7676
Disabling the decorrelation rule can also achieve the same effect:
@@ -84,20 +84,20 @@ explain select * from t1 where t1.a < (select sum(t2.a) from t2 where t2.b = t1.
8484
```
8585

8686
```sql
87-
+----------------------------------------+----------+-----------+------------------------+--------------------------------------------------------------------------------------+
88-
| id | estRows | task | access object | operator info |
89-
+----------------------------------------+----------+-----------+------------------------+--------------------------------------------------------------------------------------+
90-
| Projection_10 | 10000.00 | root | | test.t1.a, test.t1.b |
91-
| └─Apply_12 | 10000.00 | root | | CARTESIAN inner join, other cond:lt(cast(test.t1.a, decimal(10,0) BINARY), Column#7) |
92-
| ├─TableReader_14(Build) | 10000.00 | root | | data:TableFullScan_13 |
93-
| │ └─TableFullScan_13 | 10000.00 | cop[tikv] | table:t1 | keep order:false, stats:pseudo |
94-
| └─MaxOneRow_15(Probe) | 1.00 | root | | |
95-
| └─HashAgg_27 | 1.00 | root | | funcs:sum(Column#10)->Column#7 |
96-
| └─IndexLookUp_28 | 1.00 | root | | |
97-
| ├─IndexRangeScan_25(Build) | 10.00 | cop[tikv] | table:t2, index:idx(b) | range: decided by [eq(test.t2.b, test.t1.b)], keep order:false, stats:pseudo |
98-
| └─HashAgg_17(Probe) | 1.00 | cop[tikv] | | funcs:sum(test.t2.a)->Column#10 |
99-
| └─TableRowIDScan_26 | 10.00 | cop[tikv] | table:t2 | keep order:false, stats:pseudo |
100-
+----------------------------------------+----------+-----------+------------------------+--------------------------------------------------------------------------------------+
87+
+------------------------------------------+-----------+-----------+------------------------+--------------------------------------------------------------------------------------+
88+
| id | estRows | task | access object | operator info |
89+
+------------------------------------------+-----------+-----------+------------------------+--------------------------------------------------------------------------------------+
90+
| Projection_10 | 10000.00 | root | | test.t1.a, test.t1.b |
91+
| └─Apply_12 | 10000.00 | root | | CARTESIAN inner join, other cond:lt(cast(test.t1.a, decimal(10,0) BINARY), Column#7) |
92+
| ├─TableReader_14(Build) | 10000.00 | root | | data:TableFullScan_13 |
93+
| │ └─TableFullScan_13 | 10000.00 | cop[tikv] | table:t1 | keep order:false, stats:pseudo |
94+
| └─MaxOneRow_15(Probe) | 10000.00 | root | | |
95+
| └─StreamAgg_20 | 10000.00 | root | | funcs:sum(Column#14)->Column#7 |
96+
| └─Projection_45 | 100000.00 | root | | cast(test.t2.a, decimal(10,0) BINARY)->Column#14 |
97+
| └─IndexLookUp_44 | 100000.00 | root | | |
98+
| ├─IndexRangeScan_42(Build) | 100000.00 | cop[tikv] | table:t2, index:idx(b) | range: decided by [eq(test.t2.b, test.t1.b)], keep order:false, stats:pseudo |
99+
| └─TableRowIDScan_43(Probe) | 100000.00 | cop[tikv] | table:t2 | keep order:false, stats:pseudo |
100+
+------------------------------------------+-----------+-----------+------------------------+--------------------------------------------------------------------------------------+
101101
```
102102

103103
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.

0 commit comments

Comments
 (0)