子查询展开(subquery unnesting)
Query OK, 0 rows affected (0.09 sec)
obclient> create table t2(a int primary key, b int, c int);
Query OK, 0 rows affected (0.09 sec)
--- 有依赖关系的子查询被展开改写成连接
obclient> explain select * from t1 where t1.a in (select t2.b from t2 where t2.c = t1.c);
| ============================================
|0 |MERGE JOIN | |9703 |215436|
|1 | TABLE SCAN |t1 |100000 |64066 |
|2 | SORT | |10001 |129621|
|3 | SUBPLAN SCAN |VIEW1|10001 |111242|
|4 | HASH DISTINCT| |10001 |109862|
|5 | TABLE SCAN |t2 |100000 |64066 |
============================================
Outputs & filters:
0 - output([t1.a], [t1.b], [t1.c]), filter(nil),
equal_conds([t1.a = VIEW1.t2.b], [VIEW1.t2.c = t1.c]), other_conds(nil)
1 - output([t1.c], [t1.a], [t1.b]), filter(nil),
access([t1.c], [t1.a], [t1.b]), partitions(p0)
2 - output([VIEW1.t2.b], [VIEW1.t2.c]), filter(nil), sort_keys([VIEW1.t2.b, ASC], [VIEW1.t2.c, ASC])
3 - output([VIEW1.t2.b], [VIEW1.t2.c]), filter(nil),
access([VIEW1.t2.b], [VIEW1.t2.c])
4 - output([t2.b], [t2.c]), filter(nil),
distinct([t2.b], [t2.c])