如何提高mysql 排序+分组的效率问题
select * from (
select
f.device_id,
f.point_id,
f.type
from h_device_pointvalue f
ORDER BY time desc) f1
GROUP BY f1.point_id
这个sql的功能是 找到一个设备上所有所有寄存器上的最新的状态
表结构如下
id device_id point_id type time
1 1 1 2 2016-01-29 12:12:12
2 1 1 3 2016-01-29 12:12:13
3 1 2 1 2016-01-28 00:00:00
4 2 1 1 2016-01-29 00:01:01
5 2 2 2 2016-01-29 11:01:21
6 2 2 3 2016-02-02 00:00:00