这里需要提醒的是:mysql的执行计划和查询的实际执行过程并不完全吻合。如何证明这一点呢?
真正的执行过程可以通过mysql的trace工具来分析。
1,针对执行2
EXPLAIN SELECT * FROM student WHERE cid=1;
这里只显示trace结果的一部分内容:
{
"considered_execution_plans": [
{
"plan_prefix": [
] /* plan_prefix */,
"table": "`student`",
"best_access_path": {
"considered_access_paths": [
{
"access_type": "scan",
"rows": 1,
"cost": 1.2,
"chosen": true
}
] /* considered_access_paths */