All the credit goes to TECK ( Floren )
In order to optimize the code Replace
Code:
$getthreads = $db->query_read("
SELECT thread.*, post.pagetext AS preview, post.userid AS lastpuserid
FROM ".TABLE_PREFIX."thread AS thread
LEFT JOIN ".TABLE_PREFIX."deletionlog AS deletionlog ON(thread.threadid = deletionlog.primaryid AND type = 'thread')
LEFT JOIN ".TABLE_PREFIX."post AS post ON(post.postid = thread.lastpostid)
WHERE open <> 10 AND thread.lastpostid > $lastpostid
AND forumid NOT IN (0$blockforums)
AND thread.visible = '1'
AND deletionlog.primaryid IS NULL
ORDER BY lastpost DESC LIMIT 10");
with
Code:
// The number of days to scan the table for ...
// 86400 represents the number of seconds in 24hrs
$daysprune = 1;
$datecut = "AND thread.lastpost >= " . (TIMENOW - ($daysprune * 86400));
$getthreads = $db->query_read("
SELECT thread.*, post.pagetext AS preview, post.userid AS lastpuserid
FROM " . TABLE_PREFIX . "thread AS thread
LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON (thread.threadid = deletionlog.primaryid AND type = 'thread')
LEFT JOIN " . TABLE_PREFIX . "post AS post ON (post.postid = thread.lastpostid)
WHERE open <> 10 AND thread.lastpostid > $lastpostid
AND forumid NOT IN (0$blockforums)
AND thread.visible = '1'
AND deletionlog.primaryid IS NULL
$datecut
ORDER BY thread.lastpost DESC LIMIT 10
");