指定INL_JOIN，但执行计划并不走

buddyyuan
Fri, 28 Oct 2022 08:05:09 +0000

目前看好像不行，cte 部分是要独立运行出来的。

mysql> explain with b as (select id,sum(k) as num from sbtest1 group by id), a as (select * from sbtest2) select a.id ,b.num  from a,b where a.id=b.id;
+--------------------------------+-------------+-----------+-----------------------------+---------------------------------------------------------------------------+
| id                             | estRows     | task      | access object               | operator info                                                             |
+--------------------------------+-------------+-----------+-----------------------------+---------------------------------------------------------------------------+
| HashJoin_28                    | 641.82      | root      |                             | inner join, equal:[eq(sbtest.sbtest2.id, sbtest.sbtest1.id)]              |
| ├─Selection_29(Build)          | 640.00      | root      |                             | not(isnull(sbtest.sbtest2.id))                                            |
| │ └─CTEFullScan_30             | 800.00      | root      | CTE:a                       | data:CTE_1                                                                |
| └─Selection_31(Probe)          | 8000000.00  | root      |                             | not(isnull(sbtest.sbtest1.id))                                            |
|   └─CTEFullScan_32             | 10000000.00 | root      | CTE:b                       | data:CTE_0                                                                |
| CTE_1                          | 800.00      | root      |                             | Non-Recursive CTE                                                         |
| └─Selection_14(Seed Part)      | 800.00      | root      |                             | not(isnull(sbtest.sbtest2.id))                                            |
|   └─TableReader_17             | 1000.00     | root      |                             | data:TableFullScan_16                                                     |
|     └─TableFullScan_16         | 1000.00     | cop[tikv] | table:sbtest2               | keep order:false                                                          |
| CTE_0                          | 10000000.00 | root      |                             | Non-Recursive CTE                                                         |
| └─Projection_20(Seed Part)     | 10000000.00 | root      |                             | sbtest.sbtest1.id, cast(sbtest.sbtest1.k, decimal(32,0) BINARY)->Column#5 |
|   └─IndexReader_24             | 10000000.00 | root      |                             | index:IndexFullScan_23                                                    |
|     └─IndexFullScan_23         | 10000000.00 | cop[tikv] | table:sbtest1, index:k_1(k) | keep order:false                                                          |
+--------------------------------+-------------+-----------+-----------------------------+---------------------------------------------------------------------------+
13 rows in set (0.00 sec)

阅读完整话题