我有一个问题:
SELECT last_name, uid, full_name, user_name, email_address, user_photo,
count(checkin_id) as c_c, max(created_at) as mdi
FROM activity
INNER JOIN users on checkin.user_id = users.uid
INNER JOIN friends on (friends.friend_id = checkin.user_id)
WHERE friends.user_id = '1' and item_id = '2025' and
created_at >= DATE_SUB('2013-07-10 03:16:24', INTERVAL 30 DAY) and
venue_id = '5622' and is_approved = 1
GROUP by activity.user_id
ORDER by c_c desc LIMIT 30;
此查询的目标是让所有已完成相同活动的朋友进入与过去30天内相同的项目。
当我做解释时,我在checkin
表上获得了一个index_merge,用于以下索引:
venue_id_2 -> venue_id
item_id -> item_id
查询时间为:
# Query_time: 6.710844 Lock_time: 0.033860 Rows_sent: 0 Rows_examined: 16
不确定为什么只有16行的东西需要6.7秒。有任何想法吗?这里的指数应该是什么?