开启MYSQL TRACE功能
我们使用explain关键字的时候会有疑问,为什么MYSQL优化器选择了这个索引而不是另一个索引呢?
我们可以开启trace功能查看MYSQL优化器对使用各个索引计算的代价
set session optiimizer_trace="enable=on",end_markers_in_josn=on;select * from employees where name>'a';select * from information_schema.OPTIMIZER_TRACE;
set session optiimizer_trace="enable=off";
