1.using index通过二级普通索引查找,实现了覆盖索引,不用进行回表查询

2.using index condition通过二级普通索引查找,在通过索引查到的结果后还有where条件过滤,而且这个过滤筛选是只需要用二级普通索引就可以实现,不用在内存中进行判断筛选。但是需要回表查询需要的字段值。

3.using where不管有没有通过索引查找,只要加载了数据到内存进行where条件筛选,都是

4.using index & using where:查找使用了索引,但是需要的数据都在索引列中能找到,所以不需要回表查询数据

实际例子

假如有一个表xxx,给modify_date上索引

1.using index通过二级普通索引查找,实现了覆盖索引,不用进行回表查询

explain
SELECT modify_date
        from xxx

在这里插入图片描述

2.using index condition通过二级普通索引查找,需要回表

explain
SELECT *
        from xxx where modify_date > "2022-06-27 10:27:07" and modify_date < "2022-06-28 0:0:0"

在这里插入图片描述

3.using where不走索引查找

explain
SELECT *
        from xxx
        where create_date > "2022-06-27 10:27:07" and create_date < "2022-06-28 0:0:0"

在这里插入图片描述

4.using index & using where:查找使用了索引,但是需要的数据都在索引列中能找到,所以不需要回表查询数据

explain
SELECT modify_date
        from xxx where modify_date > "2022-06-27 10:27:07" and modify_date < "2022-06-28 0:0:0"

返回结果
在这里插入图片描述

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐