zoukankan      html  css  js  c++  java
  • mysql explain using index condition

    Using where:表示优化器需要通过索引回表查询数据;
    Using index:表示直接访问索引就足够获取到所需要的数据,不需要通过索引回表;
    Using index condition:在5.6版本后加入的新特性(Index Condition Pushdown);
    Using index condition 会先条件过滤索引,过滤完索引后找到所有符合索引条件的数据行,随后用 WHERE 子句中的其他条件去过滤这些数据行;

     using index condition = using index + 回表 + where 过滤

    mysql> explain select tid from test where tid < 5 ;
    +----+-------------+-------+------------+-------+---------------+---------+---------+------+------+----------+--------------------------+
    | id | select_type | table | partitions | type  | possible_keys | key     | key_len | ref  | rows | filtered | Extra                    |
    +----+-------------+-------+------------+-------+---------------+---------+---------+------+------+----------+--------------------------+
    |  1 | SIMPLE      | test  | NULL       | range | idx_tid       | idx_tid | 5       | NULL |   28 |   100.00 | Using where; Using index |
    +----+-------------+-------+------------+-------+---------------+---------+---------+------+------+----------+--------------------------+
    1 row in set, 1 warning (0.00 sec)
    
    mysql> explain select * from test where tid < 5 ;
    +----+-------------+-------+------------+-------+---------------+---------+---------+------+------+----------+-----------------------+
    | id | select_type | table | partitions | type  | possible_keys | key     | key_len | ref  | rows | filtered | Extra                 |
    +----+-------------+-------+------------+-------+---------------+---------+---------+------+------+----------+-----------------------+
    |  1 | SIMPLE      | test  | NULL       | range | idx_tid       | idx_tid | 5       | NULL |   28 |   100.00 | Using index condition |
    +----+-------------+-------+------------+-------+---------------+---------+---------+------+------+----------+-----------------------+
    1 row in set, 1 warning (0.00 sec)
  • 相关阅读:
    django开发之model篇-Field类型讲解
    Scrapy+Chromium+代理+selenium
    如何在 CentOS 7 上安装 Python 3
    分享几个简单的技巧让你的 vue.js 代码更优雅
    如何用纯 CSS 创作一副国际象棋
    如何用纯 CSS 创作一个文本淡入淡出的 loader 动画
    Java8中数据流的使用
    SpringBoot中使用mybatis-generator自动生产
    Git 同时与多个远程库互相同步
    记录Java中对url中的参数进行编码
  • 原文地址:https://www.cnblogs.com/perfei/p/14677933.html
Copyright © 2011-2022 走看看