Mysql数据库索引的使用

1.索引的使用

查询 表的锁show index from qk_auth_employee

2.走索引

EXPLAIN SELECT * from qk_auth_employee where DataDate = '2018-06-20'

3.走索引

EXPLAIN SELECT * from qk_auth_employee where DataDate <= '2018-06-20' and DataDate > '2018-06-01'

4. 不走索引

如果选择的范围太大也不走索引,可能是因为全表扫描更快

 EXPLAIN SELECT * from qk_auth_employee where DataDate <= '2010-01-20' and DataDate > '2018-06-01'

EXPLAIN SELECT * from qk_auth_employee where DataDate <= '2018-06-20'

5. 索引的级别

 const > eq_reg > ref > range > index > ALL

原文地址:https://www.cnblogs.com/gylhaut/p/9209949.html