-> Index range scan on t2 using PRIMARY (cost=2.06 rows=9) (actual time=0.035..0.038 rows=9 loops=1)
-> Index lookup on t1 using a (a=`<subquery2>`.b) (cost=2.35 rows=1) (actual time=0.010..0.010 rows=1 loops=9)
1 row in set (0.01 sec)
复制代码
可视化执行计划展示:
12种数据表访问方式作色
作色与表访问方式成本大小的关系
Blue (1) is the cheapest; green (2), yellow (3), and orange (4) represent low to medium costs; and the most expensive access types and operations are red symbolizing a high (5) to very high (6) cost.
以上都只是一个平均值or 经验值,可视化执行计划的颜色展示不是绝对的真理。
可以思考一下:索引look up 一定比全表扫描好吗?索引只会带来查询上的正向优化吗?