indexing - Mysql not use index over huge table -


i have next table:

create table `test` (  `fingerprint` varchar(80) collate utf8_unicode_ci not null,  `country` varchar(5) collate utf8_unicode_ci not null,  `loader` int(10) unsigned not null,  `date` date not null,  `installer` int(10) unsigned default null,  `browser` varchar(5) collate utf8_unicode_ci not null default '',  `version` varchar(5) collate utf8_unicode_ci not null default '',  `os` varchar(10) collate utf8_unicode_ci not null default '',  `language` varchar(10) collate utf8_unicode_ci not null default '',  primary key (`fingerprint`, `date`),  key `date_1` (`date`),  key `date_2` (`date`,`loader`,`installer`,`country`,`browser`,`os`) ) engine=innodb default charset=utf8 collate=utf8_unicode_ci; 

right contains 10m records , increase per 2m records / day.

my question, why mysql use "using where" on next query:

explain select count(*) test date between '2013-08-01' , '2013-08-10' 1   simple  test    range   date_1,date_2   date_1  3       1601644 using where; using index 

update, why next question have type - , using then:

explain select * test use key(date_1) date between '2013-08-01' , '2013-08-10' 1 simple test date_1 null null null 3648813 using 

it does use index.

it says right there: using where; using index. "using where" doesn't mean full scan, means it's using where condition provided.

the 1601644 number hints @ that: means expect read 1.6m records, not whole 10m in table, , correlates ~2m/day estimate.

in short, seems doing well, it's lot of data retrieve.

still, it's reading table data too, when seems index should enough. try changing count(*) count(date), date field mentioned in whole query. if using index, faster.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -