• mysql 执行计划走索引


    <pre name="code" class="html">mysql> desc AssignClientManager;
    +-----------------+----------+------+-----+---------+----------------+
    | Field           | Type     | Null | Key | Default | Extra          |
    +-----------------+----------+------+-----+---------+----------------+
    | sn              | int(11)  | NO   | PRI | NULL    | auto_increment |
    | clientSn        | int(11)  | NO   | MUL | NULL    |                |
    | clientManagerSn | int(11)  | NO   |     | NULL    |                |
    | status          | char(1)  | NO   |     | 1       |                |
    | createdTime     | datetime | YES  |     | NULL    |                |
    | updatedTime     | datetime | YES  |     | NULL    |                |
    +-----------------+----------+------+-----+---------+----------------+
    6 rows in set (0.00 sec)
    
    mysql> show index from AssignClientManager;
    +---------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
    | Table               | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
    +---------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
    | AssignClientManager |          0 | PRIMARY  |            1 | sn          | A         |        4934 |     NULL | NULL   |      | BTREE      |         |               |
    | AssignClientManager |          1 | ACM_IDX1 |            1 | clientSn    | A         |        4458 |     NULL | NULL   |      | BTREE      |         |               |
    +---------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
    2 rows in set (0.00 sec)
    
    mysql> explian select sn,clientSn from AssignClientManager;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'explian select sn,clientSn from AssignClientManager' at line 1
    mysql> explain select sn,clientSn from AssignClientManager;
    +----+-------------+---------------------+------------+-------+---------------+----------+---------+------+------+----------+-------------+
    | id | select_type | table               | partitions | type  | possible_keys | key      | key_len | ref  | rows | filtered | Extra       |
    +----+-------------+---------------------+------------+-------+---------------+----------+---------+------+------+----------+-------------+
    |  1 | SIMPLE      | AssignClientManager | NULL       | index | NULL          | ACM_IDX1 | 4       | NULL | 4934 |   100.00 | Using index |
    +----+-------------+---------------------+------------+-------+---------------+----------+---------+------+------+----------+-------------+
    1 row in set, 1 warning (0.00 sec)
    
    mysql> explain SELECT COUNT(sn) FROM AssignClientManager where clientSn>5;
    +----+-------------+---------------------+------------+-------+---------------+----------+---------+------+------+----------+--------------------------+
    | id | select_type | table               | partitions | type  | possible_keys | key      | key_len | ref  | rows | filtered | Extra                    |
    +----+-------------+---------------------+------------+-------+---------------+----------+---------+------+------+----------+--------------------------+
    |  1 | SIMPLE      | AssignClientManager | NULL       | range | ACM_IDX1      | ACM_IDX1 | 4       | NULL | 4928 |   100.00 | Using where; Using index |
    +----+-------------+---------------------+------------+-------+---------------+----------+---------+------+------+----------+--------------------------+
    1 row in set, 1 warning (0.00 sec)
    
    mysql> explain select * from AssignClientManager where sn <100 and clientSn <200;
    +----+-------------+---------------------+------------+-------+------------------+---------+---------+------+------+----------+-------------+
    | id | select_type | table               | partitions | type  | possible_keys    | key     | key_len | ref  | rows | filtered | Extra       |
    +----+-------------+---------------------+------------+-------+------------------+---------+---------+------+------+----------+-------------+
    |  1 | SIMPLE      | AssignClientManager | NULL       | range | PRIMARY,ACM_IDX1 | PRIMARY | 4       | NULL |   99 |     4.95 | Using where |
    +----+-------------+---------------------+------------+-------+------------------+---------+---------+------+------+----------+-------------+
    1 row in set, 1 warning (0.01 sec)


    
       
    
    
  • 相关阅读:
    HDU 5045 5047 5050 5053(上海网络赛E,F,I,L)
    Xcode 5、Xcode 6 免证书真机调试
    Ubuntu打开终端的方法三种
    JAVA异常处理机制
    Java多线程之~~~~synchronized 方法
    iphone开发技术要学习的内容
    表达式求值(数据结构书上栈的应用之中的一个)
    Java学习篇之---json-lib(Maven)
    Nginx 笔记与总结(16)nginx 负载均衡
    SPSS数据记录的选择(Select Cases)
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199932.html
Copyright © 2020-2023  润新知