create index xxx1 on teacher_info(school,id);
create index xxxs on teacher_level(teacher_id,comment_id);
create index xxxd on teacher_comment(id);
create index xxxs on teacher_level(teacher_id,comment_id);
create index xxxd on teacher_comment(id);
EXPLAIN SQL语句,贴结果
explain select ...
不要贴图,直接贴文本以供分析。
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
teacher_info 0 PRIMARY 1 id A 913108 BTREE
teacher_info 1 loveliness 1 loveliness A 6 BTREE
teacher_info 1 schoolkey 1 school A 915 BTREE
teacher_info 1 nameKey 1 name A 913108 BTREE
teacher_info 1 departmentKey 1 department A 13233 YES BTREE
teacher_info 1 isShieldKey 1 is_shield A 6 YES BTREE
teacher_info 1 id 1 id A 913108 BTREE
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
teacher_level 0 PRIMARY 1 id A 3420069 BTREE
teacher_level 1 user_id 1 user_id A 3420069 BTREE
teacher_level 1 teacher_id 1 teacher_id A 3420069 BTREE
teacher_level 1 commentkey 1 comment_id A 3420069 BTREE
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
teacher_comment 0 PRIMARY 1 id A 3369939 BTREE
teacher_comment 1 teacher_id 1 teacher_id A 3369939 BTREE
teacher_comment 1 user_id 1 user_id A 3369939 BTREE
teacher_comment 1 schoolkey 1 school_id A 1131 YES BTREE
teacher_comment 1 shieldKey 1 is_shield A 18 YES BTREE
show index from teacher_info
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality
Sub_part Null Index_Type
teacher_info 0 PRIMARY 1 id A 1016262 BTREE
teacher_info 1 loveliness 1 loveliness A 10 BTREE
teacher_info 1 schoolkey 1 school A 4748 BTREE
teacher_info 1 nameKey 1 name A 1016262 BTREE
teacher_info 1 departmentKey 1 department A 8262 YES BTREE
teacher_info 1 isShieldKey 1 is_shield A 10 YES BTREE
teacher_info 1 index_sii 1 school A 2363 BTREE
teacher_info 1 index_sii 2 id A 1016262 BTREE