使用子查询。
limit:防止优化器对sql进行优化,导致分组排序无效
SELECT
*
FROM
(
SELECT
e.event_id,
e.user_id,
e.user_name,
e.createtime
FROM
event_log e
WHERE
e.type = 10
ORDER BY
e.createtime DESC
LIMIT 100000
) t
GROUP BY
event_id
网友评论