我们有一张doris明细表如下
id user value commit_time
1 1 100 "2024-05-01 14:00:01"
2 2 200 "2024-05-01 15:00:01"
3 3 300 "2024-05-01 15:00:01"
4 1 150 "2024-05-01 15:30:01"
需求是根据user的最新commit_time得到出下列结果
2 2 200 "2024-05-01 15:00:01"
3 3 300 "2024-05-01 15:00:01"
4 1 150 "2024-05-01 15:30:01"
使用窗口函数是可以的成功得到
SELECT *
FROM (
SELECT *,
ROW_NUMBER() OVER (PARTITION BY user ORDER BY commit_time DESC) AS row_num
FROM table
) AS subquery
WHERE row_num = 1
目前问题是希望能透过物化视图加速这个查询,不用每次query都重新计算一次,但物化视图目前好像还不支援使用窗口函数,想请教一下大家有没有什么好解法?