SELECT thread.*
,
last_post_user.gender AS last_post_gender,
last_post_user.avatar_date AS last_post_avatar_date,
last_post_user.gravatar AS last_post_gravatar,
IF(last_post_user.username IS NULL, thread.last_post_username, last_post_user.username) AS last_post_username,
node.title AS node_title, node.node_name,
forum.*,
forum.last_post_id AS forum_last_post_id,
forum.last_post_date AS forum_last_post_date,
forum.last_post_user_id AS forum_last_post_user_id,
forum.last_post_username AS forum_last_post_username,
forum.last_thread_title AS forum_last_thread_title,
thread.last_post_id,
thread.last_post_date,
thread.last_post_user_id,
thread.last_post_username,
GREATEST(COALESCE(thread_read.thread_read_date, 0), COALESCE(forum_read.forum_read_date, 0), -xxxxxxxx+xx) AS thread_read_date,
permission.cache_value AS node_permission_cache
FROM xf_thread AS thread
LEFT JOIN xf_user AS last_post_user ON
(last_post_user.user_id = thread.last_post_user_id)
LEFT JOIN xf_node AS node ON
(node.node_id = thread.node_id)
LEFT JOIN xf_forum AS forum ON
(forum.node_id = thread.node_id)
LEFT JOIN xf_thread_read AS thread_read ON
(thread_read.thread_id = thread.thread_id
AND thread_read.user_id = zzz)
LEFT JOIN xf_forum_read AS forum_read ON
(forum_read.node_id = thread.node_id
AND forum_read.user_id = zzz)
LEFT JOIN xf_permission_cache_content AS permission
ON (permission.permission_combination_id = yyy
AND permission.content_type = 'node'
AND permission.content_id = thread.node_id)
WHERE (thread.discussion_type <> 'redirect') AND (thread.discussion_state IN ('visible')) AND (thread.last_post_date > -xxxxxxxx+xx) AND (forum.find_new = 1)
ORDER BY thread.last_post_date DESC
LIMIT 10
Run Time: 1.653349