0
点赞
收藏
分享

微信扫一扫

hj118888.com162287l9999提出的mysql索引问题

张宏涛心理 2022-11-05 阅读 75

mysql 5.7.21 linux 6.8

h518建立一个组合索引,在查询的时候不使用这个这个组合索引的前导列进行查询但还是走索引,请教各位!

show create table t; ±------±---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | ±------±---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | t | CREATE TABLE t ( name varchar(20) DEFAULT NULL, age int(29) DEFAULT NULL, local varchar(30) DEFAULT NULL, KEY xxxx (name,age,local) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 | ±------±---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

select count() from t; ±---------+ | count() | ±---------+ | 10000 | ±---------+

explain select name from t where local=‘xx33’; ±—±------------±------±-----------±------±--------------±-----±--------±-----±------±---------±-------------------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | ±—±------------±------±-----------±------±--------------±-----±--------±-----±------±---------±-------------------------+ | 1 | SIMPLE | t | NULL | index | NULL | xxxx | 61 | NULL | **61 | 10.00 | Using where; Using index | ±—±------------±------±-----------±------±--------------±-----±--------±-----±------±---------±-------------------------+ ————————————————

举报

相关推荐

0 条评论