我在mysql中查询执行时间有问题

时间:2015-05-19 06:36:35

标签: php mysql

这是我的查询:

SELECT mm.b_id AS b_user_id, mm.v_seo_url AS v_seo_url, C.b_id AS b_conversion_id, mm.v_first_name AS v_first_name, mm.v_last_name AS v_last_name, R.b_id AS b_message_id, R.t_message AS t_message, R.b_read_flag AS b_read_flag, R.d_date_time AS d_date_time
FROM mycom_member mm, mycom_conversation C, mycom_conversation_replay R
JOIN (

SELECT MAX( t1.d_date_time ) AS time
FROM mycom_conversation_replay t1
GROUP BY t1.b_conversation_id
ORDER BY t1.b_id DESC
) AS recent ON recent.time = R.d_date_time
WHERE CASE WHEN C.b_user_one_id =10
THEN C.b_user_two_id = mm.b_id
AND C.v_user_one_status = 'enable'
WHEN C.b_user_two_id =10
THEN C.b_user_one_id = mm.b_id
AND C.v_user_two_status = 'enable'
END AND C.b_id = R.b_conversation_id
AND (
C.b_user_one_id =10
OR C.b_user_two_id =10
)
GROUP BY R.b_conversation_id
ORDER BY R.b_id DESC
LIMIT 0 , 100

我在conversation_replay表中有300000条记录,我获得了100条记录。 它采取3.7918秒。所以我如何减慢查询执行时间。

0 个答案:

没有答案