PHP Code:
$sql = mysql_query("SELECT *
FROM thread
WHERE forumid NOT IN(3,6,11,12,19,20,24,28,29,31,32,34,35,36,37,38,40,41,43,44,45,48,49,50,52,53,58,61)AND visible IN (0,1,2)
AND sticky IN (0,1)
ORDER BY lastpost DESC LIMIT 20");
I don't understand why you select on visible and sticky, seems to me you are allowing all possible values. Take those out would speed up.
I suggest you just put back the threadid in the WHERE clause.
Then add indexes on all (on forumid, on threadid & on lastpost) columns used in a WHERE or ORDER BY clause.
This could speed up things a lot. For threadid and forumid, you can use unique indexes.