• 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)


    
       
    
    
  • 相关阅读:
    eolinker使用初体验(一)
    微信小程序--地图组件与api-模拟器上返回的scale 与真机上不同--bindregionchange触发图标一直闪现问题
    wx.createSelectorQuery() 获取节点信息 获取不到解决方法
    各种兼容
    跨域
    判断为false的情况
    linux的ssh相关指令
    js用正则表达式将英文引号字符替换为中文引号字符
    JavaScript控制iframe中元素的样式
    jQuery匹配id 批量修改css属性
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199933.html
Copyright © 2020-2023  润新知