Hello: i have this Query which is identified as a slow query. i don't have any more tricks to optimize it: ("SELECT usergroupid,avatarrevision,reputation,user.posts,user.usertitle,user.username,user.userid,COUNT(*) AS total FROM " . TABLE_PREFIX . "user AS user," . TABLE_PREFIX . "thread AS thread WHERE postuserid NOT IN ($notop) AND postuserid=thread.postuserid AND thread.dateline BETWEEN $sttopthpo AND $endtopthpo GROUP BY thread.postuserid ORDER BY total DESC LIMIT 1"); here is it in the slow query log: # Query_time: 11 Lock_time: 0 Rows_sent: 1 Rows_examined: 64 SELECT usergroupid,avatarrevision,reputation,user.posts,user.usertitle,user.username,user.userid,COUNT(*) AS total FROM user AS user,thread AS thread WHERE postuserid NOT IN (0) AND postuserid=thread.postuserid AND thread.dateline BETWEEN 1294444800 AND 1294531200 GROUP BY thread.postuserid ORDER BY total DESC LIMIT 1; i have indexed: user.userid thread.postuserid thread.dateline but still it is slow. any more thoughts?
i indexed that, but i came up with another solution that i am working on now, i will add another table and store the info in it once daily and make the script to simply read from that table instead of running this query every time a visitor comes to the site.