zoukankan      html  css  js  c++  java
  • 优化器参数-eq_range_index_dive_limit-索引下探

    5.7中当出现数据大量切斜的时候执行计划依然能够得到正确的执行计划。比如性别列索引,其中30行,29行为男性,1行为女性,下面是执行计划示例:

    mysql> set eq_range_index_dive_limit=100;
    Query OK, 0 rows affected (0.00 sec)
    mysql> desc select * from testdvi3 where sex='M';
    +----+-------------+----------+------------+------+---------------+------+---------+------+------+----------+-------------+
    | id | select_type | table    | partitions | type | possible_keys | key  | key_len | ref  | rows | filtered | Extra       |
    +----+-------------+----------+------------+------+---------------+------+---------+------+------+----------+-------------+
    |  1 | SIMPLE      | testdvi3 | NULL       | ALL  | sex           | NULL | NULL    | NULL |   30 |    96.67 | Using where |
    +----+-------------+----------+------------+------+---------------+------+---------+------+------+----------+-------------+
    1 row in set, 1 warning (2.74 sec)
    mysql> desc select * from testdvi3 where sex='W';
    +----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
    | id | select_type | table    | partitions | type | possible_keys | key  | key_len | ref   | rows | filtered | Extra |
    +----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
    |  1 | SIMPLE      | testdvi3 | NULL       | ref  | sex           | sex  | 9       | const |    1 |   100.00 | NULL  |
    +----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
    1 row in set, 1 warning (2.00 sec)
    mysql> set eq_range_index_dive_limit=1;
    Query OK, 0 rows affected (0.00 sec)
    mysql> desc select * from testdvi3 where sex='W';
    +----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
    | id | select_type | table    | partitions | type | possible_keys | key  | key_len | ref   | rows | filtered | Extra |
    +----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
    |  1 | SIMPLE      | testdvi3 | NULL       | ref  | sex           | sex  | 9       | const |   15 |   100.00 | NULL  |
    +----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
    1 row in set, 1 warning (0.00 sec)
    mysql> desc select * from testdvi3 where sex='M';
    +----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
    | id | select_type | table    | partitions | type | possible_keys | key  | key_len | ref   | rows | filtered | Extra |
    +----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
    |  1 | SIMPLE      | testdvi3 | NULL       | ref  | sex           | sex  | 9       | const |   15 |   100.00 | NULL  |
    +----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
    

      使用限制

    • 唯一条件的等值查询也不会使用索引下探(= in or )。
    • 一般是非唯一索引或者范围查询(< > <= >=)才会用到索引下探,实际上他们都是‘RANGE’。
    螃蟹在剥我的壳,笔记本在写我,漫天的我落在枫叶上雪花上,而你在想我。 --章怀柔
  • 相关阅读:
    win10x64位系统中nodejs的安装和配置
    My97 DatePicker获取自定义日期的前一天
    easyUI在使用字符串拼接时样式不起作用,点击加号增加一行,点击减号删除一行效果。
    easyUI datagarid单元格动态合并
    js单体内置对象
    [BZOJ 1878][SDOI2009]HH的项链
    [BZOJ 3932][CQOI2015]任务查询系统
    [BZOJ 3123] 森林
    [BZOJ 3295] 动态逆序对
    [BZOJ 1901] Dynamic Rankings
  • 原文地址:https://www.cnblogs.com/lovezhr/p/13407299.html
Copyright © 2011-2022 走看看