- 论坛徽章:
- 0
|
innodb的索引也是一个占空间的地方,每一个索引都会把主键带上.
比如
CREATE TABLE `u` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`us` mediumint( unsigned NOT NULL,
`ty` tinyint(3) unsigned NOT NULL,
`ta` tinyint(3) unsigned NOT NULL,
`su` tinyint(3) unsigned NOT NULL,
`ch` varchar(14) NOT NULL,
`it` int(10) unsigned NOT NULL,
`mo` int(10) unsigned NOT NULL,
`st` tinyint(3) unsigned NOT NULL,
`ac` int(10) unsigned NOT NULL,
`de` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `a` (`ac`),
KEY `i` (`it`),
KEY `u` (`us`,`ac`),
KEY `d` (`de`),
KEY `t` (`ta`,`su`),
KEY `t_a` (`ta`,`ac`)
) ENGINE=InnoDB
索引a,i,u,d,t,t_a都会把id放进去.
你可以试试
explain select id from u where de = 3
他会只读索引文件而不会去读数据返回结果 |
|