I have this query:
SELECT * FROM table WHERE x >= 500 AND x < 5000 ORDER BY date DESC LIMIT 0,50
I have index: x, date – Btree
Why is this query using index and filesort, if I have index on both values.
x= integer
date = date
tyble type = myisam
explain:
ID: 1 select_type: SIMPLE table: d type: range possible_keys: sort key: sort key_len: 2 ref: null rows: 198 extra: using index condition; using filesort
The query is using filesort because it is a range query. Filesort would desappear if the query used exact equation.
But you probably know that filesort is actualy a misname and has actually no relation to files.