explain select id, profession from tb_ user where profession= '软件工程’and age=31 and status= '0' ;
explain select id,profession,age, status from tb_user where profession= '软件工程’and age=31 and status='0' ;
explain select id,profession,age, status, name from tb_ _user where profession= '软件工程' and age=31 and status= '0' ;
explain select
from tb_user where profession= '软件工程’and age=31 and status= '0' ;
复制代码
知识小贴士:
using index condition:查找使用了索引,但是必要回表查询数据
sing where; using index :查找使用了索引,但是必要的数据都在索引列中能找到,所以不必要回表查询数据
这里就涉及到聚集索引和二级索引(辅助索引),会回表的问题,在二级索引中返回id再去聚集索引中进行查找返回信息。
1.索引概述
索引是高效获取数据的数据结构; 2.索引结构
B+Tree
Hash 3.索引分类
主键索引、唯一索引、通例索引、全文索引
聚集索引、二级索引 4.索引语法
create [unique ] index xx on xxxx);
show index from XXXX ;
drop index xXxx on XXXX ; 5.SQL性能分析
执行频次、慢查询日志、profile、 explain 6.索引使用
团结索引
索引失效
SQL提示
覆盖索引
前缀索引
单列/团结索引 7.索引设计原则
表
字段
60K5-1725868393368)]
黑马步伐制作的图,团结索引的二级索引。
1.7 索引的设计原则
1.索引概述
索引是高效获取数据的数据结构; 2.索引结构
B+Tree
Hash 3.索引分类
主键索引、唯一索引、通例索引、全文索引
聚集索引、二级索引 4.索引语法
create [unique ] index xx on xxxx);
show index from XXXX ;
drop index xXxx on XXXX ; 5.SQL性能分析
执行频次、慢查询日志、profile、 explain 6.索引使用
团结索引
索引失效
SQL提示
覆盖索引
前缀索引
单列/团结索引 7.索引设计原则
表
字段
索引