SELECT COUNT(*)
FROM xf_thread AS thread
WHERE (thread.node_id = 69) AND (thread.sticky = 0) AND (thread.discussion_state IN ('visible'))

Run Time: 0.000158

Select Type

Table

Type

Possible Keys

Key

Key Len

Ref

Rows

Extra

SIMPLE

thread

ref

node_id_last_post_date,node_id_sticky_last_post_date

node_id_last_post_date

4

const

11

Using where

SELECT thread.*
,
user.*, IF(user.username IS NULL, thread.username, user.username) AS username,
NULL AS thread_read_date,
0 AS user_post_count
FROM xf_thread AS thread
LEFT JOIN xf_user AS user ON
(user.user_id = thread.user_id)
WHERE (thread.node_id = 69) AND (thread.sticky = 0) AND (thread.discussion_state IN ('visible'))
ORDER BY thread.last_post_date DESC
LIMIT 20

Run Time: 0.001396

Select Type

Table

Type

Possible Keys

Key

Key Len

Ref

Rows

Extra

SIMPLE

thread

ref

node_id_last_post_date,node_id_sticky_last_post_date

node_id_last_post_date

4

const

11

Using where

SIMPLE

user

eq_ref

PRIMARY

PRIMARY

4

dichvudi_forumtruyen.thread.user_id

1

SELECT thread.*
,
user.*, IF(user.username IS NULL, thread.username, user.username) AS username,
NULL AS thread_read_date,
0 AS user_post_count
FROM xf_thread AS thread
LEFT JOIN xf_user AS user ON
(user.user_id = thread.user_id)
WHERE (thread.node_id = 69) AND (thread.sticky = 1) AND (thread.discussion_state IN ('visible'))
ORDER BY thread.last_post_date DESC

Run Time: 0.000946

Select Type

Table

Type

Possible Keys

Key

Key Len

Ref

Rows

Extra

SIMPLE

thread

ref

node_id_last_post_date,node_id_sticky_last_post_date

node_id_sticky_last_post_date

5

const,const

1

Using where

SIMPLE

user

eq_ref

PRIMARY

PRIMARY

4

dichvudi_forumtruyen.thread.user_id

1

SELECT *
FROM xf_node
WHERE lft > ? AND rgt < ?
AND display_in_list = 1
ORDER BY lft ASC