关于mysql复合索引

来源:互联网 发布:域名续费越来越贵 编辑:程序博客网 时间:2024/05/17 08:04

http://www.cnblogs.com/joyber/p/4349604.html


 CREATE TABLE `log` (  `id` int(20) NOT NULL AUTO_INCREMENT,  `t11` int(11) NOT NULL ,  `t22` int(11) NOT NULL ,  `logtime` int(11) NOT NULL,  PRIMARY KEY (`id`),  KEY `gssindex` (`t11`,`t22`)) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8;mysql> explain select * from log where t22=11111 \G                       *************************** 1. row ***************************           id: 1  select_type: SIMPLE        table: log         type: ALLpossible_keys: NULL          key: NULL      key_len: NULL          ref: NULL         rows: 110463        Extra: Using where1 row in set (0.01 sec)mysql> explain select * from log where t11=11111 \G    *************************** 1. row ***************************           id: 1  select_type: SIMPLE        table: log         type: refpossible_keys: gssindex          key: gssindex      key_len: 4          ref: const         rows: 1        Extra: NULL1 row in set (0.00 sec)mysql> 


原创粉丝点击