Doris版本:0.14.7
在使用过程中,遇到一系列与row_number over相关的,问题,希望可以关注优化一下。
1. BE的OOM问题中,将ETL过程中的row_number over修改为group by之后,OOM问题得到了改善。
2.当视图中存在row_number over 时,查询视图时加limit,会优先计算row_number,再进行limit,导致出结果非常的缓慢。
3.当视图中存在row_number over,且包含比较多的join(5个或以上)时,容易报错:can't support
出错的view:
create view ods_dental.vw_dental_appointmentitem as
select
a.tenantid,a.appointmentid,
a.AppointmentItemCode,a.AppointmentItemName,
b.transactionid as AppointmentFirstItemCode,
b.name as AppointmentFirstItemName
from (
select
main.tenantid,main.appointmentid,
group_concat(t.name) as AppointmentItemName, group_concat(main.transactionid) as AppointmentItemCode
FROM ods_dental.ods_dental_appointmentprocedure main
INNER JOIN ods_dental.vw_aresglobal g ON
g.globaltenantid = main.tenantid
AND g.dbname = main.systemdbname
LEFT OUTER JOIN ods_dental.ods_dental_transactioncode t ON main.tenantid = t.tenantid
AND main.transactionid = t.id
AND main.systemdbname = t.systemdbname
AND t.isdeleted = 0
where main.isdeleted=0 and main.isinactive=0
group by main.tenantid,main.appointmentid
) a
left join
(
select
main.tenantid,main.appointmentid,main.transactionid,t.name,
row_number() OVER (PARTITION BY main.tenantid, main.appointmentid
ORDER BY main.isdeleted ASC, main.id ASC) rnk
from ods_dental.ods_dental_appointmentprocedure main
INNER JOIN ods_dental.vw_aresglobal g ON
g.globaltenantid = main.tenantid
AND g.dbname = main.systemdbname
LEFT OUTER JOIN ods_dental.ods_dental_transactioncode t ON main.tenantid = t.tenantid
AND main.transactionid = t.id
AND main.systemdbname = t.systemdbname
AND t.isdeleted = 0
where main.isdeleted=0 and main.isinactive=0) b on a.tenantid=b.tenantid and a.appointmentid=b.appointmentid
and b.rnk=1
view中
create view vw_XXX as
select *,row_number() over(patition by v1,v2 order by k1)rn
from table
外部查询
select * from vw_XXX limit 100
会先做row_number的操作,再limit100
你说的问题2 的带limit 的查询样子是?