MySQL using index condition

2022-7-19 15:30:59 星期二

查看MySQL explain的时候, 最后一列看到了 using index condition, 查了查网上资料, 自己试了试, 出现的场景如下:

SQL中使用了 join, 并且 on 中的两个字段的数据类型不一致,

我的两个表中, join用的两个字段, 一个是char, 一个是varchar,

都改成 char后, 再explain 就没有 using index condition 了

 

参考: 

https://www.fujieace.com/mysql/extra-using-index-condition.html

https://www.likecs.com/show-204613174.html

https://www.likecs.com/show-305433161.html

官网: https://dev.mysql.com/doc/refman/8.0/en/explain-output.html#explain_extra

Using index condition (JSON property: using_index_condition)

Tables are read by accessing index tuples and testing them first to determine whether to read full table rows. In this way, index information is used to defer (“push down”) reading full table rows unless it is necessary

感觉网上其他文章的翻译比较拗口(常见到"表行"这个词, 很诡异, 应该是从翻译工具中直接贴出来的), 我自己试着翻译:

读表之前, 先尝试通过访问(查询)索引元组来决定是否读取全表的数据; 

这种情况下, 如非必要, 索引信息常用来延迟(避免)读取表中所有行的数据;

(言下之意是还可能要回表的, 但是否扫全表还不确定, 要看索引信息了??) 

 

posted @ 2022-07-19 15:34  myD  阅读(314)  评论(0编辑  收藏  举报