mysql explain

文章目录


  • 也不想多写什么
  • https://dev.mysql.com/doc/refman/8.0/en/explain-output.html
  • https://dev.mysql.com/doc/refman/5.7/en/explain-output.html

在这里插入图片描述

  • 需要说明的是 extra 的 Using where,网上很多解释是此信息表明需要回表查询;但是在 字段a的索引上执行 select a from t where a>1 这种类似的语句也会出现 Using where,这从逻辑上就说不过去,mysql 的优化器也没有这么傻吧;
  • 文档中的原文是这样的:

Using where (JSON property: attached_condition)
A WHERE clause is used to restrict which rows to match against the next table or send to the client. Unless you specifically intend to fetch or examine all rows from the table, you may have something wrong in your query if the Extra value is not Using where and the table join type is ALL or index.
Using where has no direct counterpart in JSON-formatted output; the attached_condition property contains any WHERE condition used.

  • 直白的翻译是:WHERE 子句用于限制哪些行与下一个表匹配或发送给客户机。除非您特意打算从表中获取或检查所有行,否则如果额外的值没有使用where,并且表联接类型为all或index,则查询中可能有错误。
  • 简要概括是:使用 where 子句中的字段进行结果过滤。
  • 并没有表明需要回表之类的操作,至少从文档解释来看是没有的;而sql执行逻辑上也是没有必要的。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值