zoukankan      html  css  js  c++  java
  • 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)


    
                                        
    
  • 相关阅读:
    9.8-9.9多校互测与牛客网提高一测
    数位$dp$
    互不侵犯_状压$dp$
    状态压缩dp初学__$Corn Fields$
    树形$dp$学习笔记
    最长公共上升子序列$LCIS$
    区间dp学习笔记
    保护知识产权,让创新更有动力!
    crmeb后台七牛云存储相关配置步骤
    crmeb一款最适合二次开发的开源微信公众号小程序框架
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350731.html
Copyright © 2011-2022 走看看