一、单表查询索引列和查询索引列+其他非索引列 查询数据速度为什么有差?为什么查询非索引列会不走索引?
现象: 单个表,结构如下:
CREATE TABLE `t_attach_new` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`fname` varchar(100) NOT NULL DEFAULT ‘‘,
`ftype` varchar(50) DEFAULT ‘‘,
`fkey` text NOT NULL,
`authorId` int(10) DEFAULT NULL,
`created` int(10) NOT NULL,
`hash` varchar(255) DEFAULT NULL,
`web_url` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fname` (`fname`),
KEY `created` (`created`),
KEY `id` (`id`,`created`),
KEY `created_2` (`created`,`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2621401 DEFAULT CHARSET=utf8;
查询语句,下面两个。
EXPLAIN SELECT id,fname,web_url FROM t_attach_new LIMIT 2000000,10;
EXPLAIN SELECT id,fname FROM t_attach_new LIMIT 2000000,10;
TODO 待解答