https://docs.pingcap.com/zh/tidb/dev/sql-prepared-plan-cache
你参照这个看下sql 使用的执行计划是不是缓存的
MySQL [test]> select @@last_plan_from_cache; – 选择计划缓存
±-----------------------+
| @@last_plan_from_cache |
±-----------------------+
| 1 |
±-----------------------+
1 row in set (0.00 sec)
MySQL [test]> admin flush session plan_cache; – 清空当前 session 的计划缓存
Query OK, 0 rows affected (0.00 sec)
MySQL [test]> execute stmt;
Empty set (0.00 sec)
MySQL [test]> select @@last_plan_from_cache; – 由于缓存被清空,此时无法再次选中
±-----------------------+
| @@last_plan_from_cache |
±-----------------------+
| 0 |
±-----------------------+
1 row in set (0.00 sec)