|
本帖最后由 gyjohn 于 2013-1-11 16:42 编辑
EXPLAIN --不用索引
select count(*) from table_name N0 ignore index(INDEX_LOGIN,INDEX_CLOSETIME)
where (N0.`CLOSE_TIME` >= '2012/11/21') and (N0.`CLOSE_TIME` < '2012/11/22') and N0.`Login` = 3000id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | 1 | SIMPLE | N0 | ALL | (null) | (null) | (null) | (null) | 3877541 | Using where |
EXPLAIN --用索引
select count(*) from table_name N0
where (N0.`CLOSE_TIME` >= '2012/11/21') and (N0.`CLOSE_TIME` < '2012/11/22') and N0.`Login` = 3000
id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | 1 | SIMPLE | N0 | range | INDEX_LOGIN,INDEX_CLOSETIME | INDEX_CLOSETIME | 8 | (null) | 61590 | Using where |
|
|