mysql中explain语句查询sql是否走索引,extra中的几种类型整理汇总

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"

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

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值