57,065
社区成员
发帖
与我相关
我的任务
分享
/*DDL Information For - test.song*/
-----------------------------------
Table Create Table
------ ----------------------------------------------------------------------------------------
song CREATE TABLE `song` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Autoincreament element',
`name` char(200) DEFAULT NULL,
`datetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`rank` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `k_name` (`name`)
) ENGINE=MyISAM AUTO_INCREMENT=8102001 DEFAULT CHARSET=gbk
select count(*) from song;
explain select count(1) from song where `name` = 't1';
count(*)
8102000
query result(1 records)
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE song ref k_name k_name 401 const 2 Using where; Using index
我这个里面只是扫描了两行而已,虽然表有八百多行。