SELECT *FROM (SELECT id,value,create_time FROM `table_a` ORDER BY create_time DESC) test GROUP BY id ORDER BY create_time DESC LIMIT 0,30SELECT a.id, a.value, a.create_timeFROM `table_a`LEFT JOIN (SELECT id,max(create_time) AS toptime FROM `table_a` GROUP BY id) as b ON a.id=b.idWHERE a.create_time=b.toptimeORDER BY a.create_time DESCLIMIT 0,30 以上两个sql分别要9秒和6秒。共有一百多万条数据,求教怎样能够快点,需分页,最好做到1秒以内。多次查询也可以。
添加回答
举报
0/150
提交
取消