SELECT xf_thread.*, xf_user.*, xf_post.message, xf_post.attach_count, xf_node.title AS node_title,
IF(xf_user.username IS NULL, xf_thread.username, xf_user.username) AS username,
IF(EWRporta_promotes.promote_date IS NULL, xf_thread.post_date, EWRporta_promotes.promote_date) AS promote_date,
EWRporta_promotes.promote_icon, EWRporta_promotes.promote_data
FROM xf_thread
LEFT JOIN xf_user ON (xf_user.user_id = xf_thread.user_id)
INNER JOIN xf_post ON (xf_post.post_id = xf_thread.first_post_id)
INNER JOIN xf_node ON (xf_node.node_id = xf_thread.node_id)
LEFT JOIN EWRporta_promotes ON (EWRporta_promotes.thread_id = xf_thread.thread_id)
WHERE ( xf_thread.node_id IN ('109') OR EWRporta_promotes.promote_date < ? )
AND xf_thread.discussion_state = 'visible'
AND IF(EWRporta_promotes.promote_date IS NULL, xf_thread.post_date, EWRporta_promotes.promote_date) < ?
ORDER BY promote_date DESC
LIMIT ?, ?
Params: 1393070876, 1393070876, 0, 10
Run Time: 0.916767
Select Type Table Type Possible Keys Key Key Len Ref Rows Extra
SIMPLE xf_thread ALL node_id_last_post_date,node_id_sticky_state_last_post 262728 Using where; Using temporary; Using filesort
SIMPLE xf_node eq_ref PRIMARY PRIMARY 4 mus37_xenforo.xf_thread.node_id 1
SIMPLE EWRporta_promotes eq_ref PRIMARY PRIMARY 4 mus37_xenforo.xf_thread.thread_id 1 Using where
SIMPLE xf_user eq_ref PRIMARY PRIMARY 4 mus37_xenforo.xf_thread.user_id 1
SIMPLE xf_post eq_ref PRIMARY PRIMARY 4 mus37_xenforo.xf_thread.first_post_id 1