I've got a table with int
field, let's call it createTime
. The table consists of few million records. Now I want to run the query:
select * from `table` order by `createTime` desc limit 500000, 10
I've created an index for createTime
, but the query runs INCREDIBLY slow. What's the reason? How can I improve it?
Here's what EXPLAIN says:
id 1
select_type simple
table table
type index
possible_keys null
key createTime
key_len 4
ref null
rows 500010
extra
As for the offset, it's working much faster when it's small.
table
order bycreateTime
desc limit 500000, 10. Out of interest, what data type is createTime? – dash Dec 11 '11 at 20:30EXPLAIN
says? Since you're asking for alternative interpretations of the data... – Lightness Races in Orbit Dec 11 '11 at 20:45