mysql explain - yaokun123/php-wiki GitHub Wiki
Mysql分析
一、Explain
键 |
值 |
id |
选择标识符,id越大最先执行 |
select_type |
SIMPLE,PRIMARY, UNION, DEPENDENT UNION,UNION RESULT,SUBQUERY,DEPENDENT SUBQUERY,DERIVED,UNCACHEABLE SUBQUERY |
table |
数据库中表名称 |
type |
ALL、index、range、 ref、eq_ref、const、system、NULL(从左到右,性能从差到好) |
possible_keys |
可能用到的索引 |
Key |
实际用到的索引 |
key_len |
索引长度,可以判断复合索引使用情况 |
ref |
|
rows |
估算出结果集行数 |
Extra |
Using where,Using temporary,Using filesort |
二、optimizer trace
# 1、开启
SET optimizer_trace="enabled=on",end_markers_in_json=on;
# 2、设置记录大小
SET optimizer_trace_max_mem_size=1638400
SELECT create_time FROM person WHERE NAME >'name84059' AND create_time > '2020-05-23 14:39:18';
SELECT * FROM information_schema.OPTIMIZER_TRACE;
# 4、关闭
SET optimizer_trace="enabled=off";