SELECT post.*
,
thread.*, thread.user_id AS thread_user_id, thread.username AS thread_username,
thread.post_date AS thread_post_date,
post.user_id, post.username, post.post_date,
node.title AS node_title, node.node_name,
user.*, IF(user.username IS NULL, post.username, user.username) AS username,
permission.cache_value AS node_permission_cache, (select count(*) from dark_postrating pr USE INDEX (`post_id_rating`) where pr.post_id = post.post_id and pr.rating = 1) as dark_postrating_1_count
, (select count(*) from dark_postrating pr USE INDEX (`post_id_rating`) where pr.post_id = post.post_id and pr.rating = 14) as dark_postrating_14_count
, (select count(*) from dark_postrating pr USE INDEX (`post_id_rating`) where pr.post_id = post.post_id and pr.rating = 2) as dark_postrating_2_count
, (select count(*) from dark_postrating pr USE INDEX (`post_id_rating`) where pr.post_id = post.post_id and pr.rating = 3) as dark_postrating_3_count
, (select count(*) from dark_postrating pr USE INDEX (`post_id_rating`) where pr.post_id = post.post_id and pr.rating = 4) as dark_postrating_4_count
, (select count(*) from dark_postrating pr USE INDEX (`post_id_rating`) where pr.post_id = post.post_id and pr.rating = 5) as dark_postrating_5_count
, (select count(*) from dark_postrating pr USE INDEX (`post_id_rating`) where pr.post_id = post.post_id and pr.rating = 6) as dark_postrating_6_count
, (select count(*) from dark_postrating pr USE INDEX (`post_id_rating`) where pr.post_id = post.post_id and pr.rating = 7) as dark_postrating_7_count
, (select count(*) from dark_postrating pr USE INDEX (`post_id_rating`) where pr.post_id = post.post_id and pr.rating = 8) as dark_postrating_8_count
, (select count(*) from dark_postrating pr USE INDEX (`post_id_rating`) where pr.post_id = post.post_id and pr.rating = 9) as dark_postrating_9_count
, (select count(*) from dark_postrating pr USE INDEX (`post_id_rating`) where pr.post_id = post.post_id and pr.rating = 10) as dark_postrating_10_count
, (select count(*) from dark_postrating pr USE INDEX (`post_id_rating`) where pr.post_id = post.post_id and pr.rating = 11) as dark_postrating_11_count
, (select count(*) from dark_postrating pr USE INDEX (`post_id_rating`) where pr.post_id = post.post_id and pr.rating = 12) as dark_postrating_12_count
, (select count(*) from dark_postrating pr USE INDEX (`post_id_rating`) where pr.post_id = post.post_id and pr.rating = 13) as dark_postrating_13_count
,(select sum(count_received) from dark_postrating_count where user_id = post.user_id and rating in (1,2,4,5,7,8,10)) as positive_rating_count
,(select sum(count_received) from dark_postrating_count where user_id = post.user_id and rating in (14,11,12,13)) as negative_rating_count
,(select sum(count_received) from dark_postrating_count where user_id = post.user_id and rating in (3,6,9)) as neutral_rating_count
,
pr2.rating, rating.fb_percent, rating.fb_positive, rating.fb_positivetotal, rating.fb_negative, rating.fb_neutral,
permission_combination.cache_value AS global_permission_cache
FROM xf_post AS post
INNER JOIN xf_thread AS thread ON
(thread.thread_id = post.thread_id)
INNER JOIN xf_node AS node ON
(node.node_id = thread.node_id)
LEFT JOIN xf_user AS user ON
(user.user_id = post.user_id)
LEFT JOIN xf_permission_cache_content AS permission
ON (permission.permission_combination_id = 1
AND permission.content_type = 'node'
AND permission.content_id = thread.node_id)
LEFT JOIN dark_postrating pr2 ON (post.post_id = pr2.post_id and pr2.user_id = 0)
LEFT JOIN xc_trade_user AS rating ON rating.user_id=post.user_id
LEFT JOIN xf_permission_combination AS permission_combination ON
(permission_combination.permission_combination_id = user.permission_combination_id)
WHERE post.post_id = ?
Params: 295178
Run Time: 0.001859
Select Type | Table | Type | Possible Keys | Key | Key Len | Ref | Rows | Extra |
---|
PRIMARY | post | const | PRIMARY,thread_id_post_date,thread_id_position | PRIMARY | 4 | const | 1 | |
PRIMARY | thread | const | PRIMARY,node_id_last_post_date,node_id_sticky_state_last_post | PRIMARY | 4 | const | 1 | |
PRIMARY | node | const | PRIMARY | PRIMARY | 4 | const | 1 | |
PRIMARY | user | const | PRIMARY | PRIMARY | 4 | const | 1 | |
PRIMARY | permission | const | PRIMARY | PRIMARY | 35 | const,const,const | 1 | |
PRIMARY | pr2 | const | post_id_user_id,post_id_rating,user_id_rating | post_id_user_id | 8 | const,const | 0 | unique row not found |
PRIMARY | rating | const | PRIMARY | PRIMARY | 4 | const | 1 | |
PRIMARY | permission_combination | const | PRIMARY | PRIMARY | 4 | const | 1 | |
SUBQUERY | dark_postrating_count | range | user_id_rating | user_id_rating | 8 | | 3 | Using index condition |
SUBQUERY | dark_postrating_count | range | user_id_rating | user_id_rating | 8 | | 4 | Using index condition |
SUBQUERY | dark_postrating_count | range | user_id_rating | user_id_rating | 8 | | 7 | Using index condition |
SUBQUERY | pr | ref | post_id_rating | post_id_rating | 8 | const,const | 1 | Using index |
SUBQUERY | pr | ref | post_id_rating | post_id_rating | 8 | const,const | 1 | Using index |
SUBQUERY | pr | ref | post_id_rating | post_id_rating | 8 | const,const | 1 | Using index |
SUBQUERY | pr | ref | post_id_rating | post_id_rating | 8 | const,const | 1 | Using index |
SUBQUERY | pr | ref | post_id_rating | post_id_rating | 8 | const,const | 1 | Using index |
SUBQUERY | pr | ref | post_id_rating | post_id_rating | 8 | const,const | 1 | Using index |
SUBQUERY | pr | ref | post_id_rating | post_id_rating | 8 | const,const | 1 | Using index |
SUBQUERY | pr | ref | post_id_rating | post_id_rating | 8 | const,const | 1 | Using index |
SUBQUERY | pr | ref | post_id_rating | post_id_rating | 8 | const,const | 1 | Using index |
SUBQUERY | pr | ref | post_id_rating | post_id_rating | 8 | const,const | 1 | Using index |
SUBQUERY | pr | ref | post_id_rating | post_id_rating | 8 | const,const | 1 | Using index |
SUBQUERY | pr | ref | post_id_rating | post_id_rating | 8 | const,const | 1 | Using index |
SUBQUERY | pr | ref | post_id_rating | post_id_rating | 8 | const,const | 1 | Using index |
SUBQUERY | pr | ref | post_id_rating | post_id_rating | 8 | const,const | 1 | Using index |