在网络上,看到过这样的mysql语句,但是在效率极差。
如:
select a.* from tb a where 2 > (select count(*) from tb where name = a.name and val < a.val ) order by a.name,a.val
目前,单表数据量是77508.
该表预算数据量最大是60W左右。
不知道怎么写才比较合理?
...全文
13189打赏收藏
mysql 分组取每组时间最靠前的两条数据
在网络上,看到过这样的mysql语句,但是在效率极差。 如: select a.* from tb a where 2 > (select count(*) from tb where name = a.name and val < a.val ) order by a.name,a.val 目前,单表数据量是77508. 该表预算数据量最大是60W左右。 不知道怎么写才比较合理?