请问我这个视图能优化吗?
create or replace view v_biz_hadhandled as
select f1.*,f3.flowstepname as nextworkname from
(select ff.*,j.cetf_id,j.live_address,j.rpr_live_jd
from t_biz_hadhandled ff,v_jz_app p,jz_basic_person j
where ff.biztableid=p.pid(+)
and j.pid=p.person_id
and ff.person_name is not null
union all
select ff.*,null,null,null from t_biz_hadhandled ff where ff.person_name is null
)f1,(
select f.biztableid,MAX(F.PCTIME)
AS max_pctime,max(f.flowstep)
as max_flowstep from t_biz_hadhandled f
group by f.biztableid,f.senderid
) f2,t_bizwaithandle f3
where f1.biztableid=f2.biztableid
and f1.pctime=f2.max_pctime
and f1.flowstep=max_flowstep
and f3.biztableid(+)=f1.biztableid
;
我已经建立了索引,但感觉速度还是不理想,想问问各位大哥看这个语句能不能修改下,使查询更快。
------解决方案--------------------
SQL code
create or replace view v_biz_hadhandled as
select ff.*,
j.cetf_id,
j.live_address,
j.rpr_live_jd,
f3.flowstepname as nextworkname
from t_biz_hadhandled ff
left join v_jz_app p on ff.biztableid = p.pid
and ff.person_name is not null
left join jz_basic_person j on j.pid = p.person_id
left join t_bizwaithandle f3 on f3.biztableid = ff.biztableid
where exists
(select 1
from t_biz_hadhandled
where biztableid = ff.biztableid
group by senderid
having MAX(PCTIME) = ff.pctime and max(flowstep) = ff.flowstep)