SELECT COUNT(ID) total
FROM screenshot WHERE DateTaken BETWEEN '2000-05-01' AND '2000-06-10'
Result : 2828844
ID|select_type| table |type |possible_keys| key |key_len| rows |Extra
1 | SIMPLE |screenshot|range| DateTaken |DateTaken| 3 |5730138|Using where; Using index
Here is my problem:
I have added index to DateTaken column and yet the scanning rows (Explain output) is bigger than the result. It seems like it does a whole scan table. And the Query runtime for the query takes 15 seconds. How can I improve the speed in the query above?