Run this into your query analyzer:
[sql]SELECT threadid
FROM thread
WHERE postusername = 'John'
AND dateline > (UNIX_TIMESTAMP(NOW()) - 172800)
AND visible = 1
-- you should really add perms here
ORDER BY lastpostid, threadid DESC
LIMIT 15;[/sql]
This query will scan the table thread for any activity done last 2 days only. It will not scan anything prior to that date event, resulting in a lot less memory usage, load to the server, etc.
In other words, you will not scan the hole table, then drop all results and keep only 15.
When I ment the smallest value, I ment this: 172800 (60 * 60 * 24 * 2)
If you have a lot of threads posted evey day, you might need to set this value 120 (1 hour).
Since you only need few threads to be displayed, experiment until you get the best time window.
Edit: You should not rely only on the dateline cut. Make sure you add another condition that will cut down even further the scanning. (like I did with username John)
|