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’。
    螃蟹在剥我的壳,笔记本在写我,漫天的我落在枫叶上雪花上,而你在想我。 --章怀柔
  • 相关阅读:
    hdu 刷题记录
    HDU step by step
    Codeforces Round #260 (Div. 2) B. Fedya and Maths
    Codeforces Round #260 (Div. 2) A. Laptops
    UVALive 6662 TheLastAnt
    UVALive 6661 Equal Sum Sets
    Codeforces Round #253 (Div. 2) A. Anton and Letters
    wikioi 3130 CYD刷题(背包)
    wikioi 1014 装箱问题(背包)
    [转]很特别的一个动态规划入门教程
  • 原文地址:https://www.cnblogs.com/lovezhr/p/13407299.html
Copyright © 2011-2022 走看看