Ok, I actually inserted 5,000,000 records.... and here are my results:
Code:
SELECT * FROM logs_table ORDER BY `time` DESC LIMIT 0, 13
0.04 seconds!!!
With no index on `time`, it's 9.8 seconds (makes me think `time` is not indexed!)
Code:
SELECT *
FROM (
SELECT *
FROM logs_table
WHERE `time` > NOW() - INTERVAL 3 DAY
) AS `logs`
ORDER BY `time` DESC
LIMIT 0, 13
4 seconds!!! The inner query is returning 100,000+ records, and that's killing the index... So I reduced that timeframe and got:
Code:
SELECT * FROM (
SELECT *
FROM logs_table
WHERE `time` > NOW() - INTERVAL 10 MINUTE
) AS `logs`
ORDER BY `time` DESC
LIMIT 0, 13;
0.01 seconds
Still, it seems your problem is no index on the `time` column... go back to my first post and run the ALTER TABLE query.
Bookmarks