我有一个请求,请告诉我如何优化它?
select distinct
trunc(dw.mdf_date) as mdf_date
,dw.dss_id
,dw.raid
,dw.host_type
,dw.volume_name
,dw.volume_size
,dw.prv
,listagg(dw.hba_wwn,',' on overflow truncate '...' without count) within group (order by dw.hba_wwn) as wwn
from
dss_wwn dw
where
dw.volume_name not in ('ADMIN')
and dw.volume_name not like '.%'
and dw.hba_wwn is not null
and not exists (select 1 from wwn shw where shw.wwn = dw.hba_wwn and shw.dic_type_eqp_id = 4 and rownum = 1)
and not exists (select 1 from dss_vmhdd shw where shw.wwid = dw.disk_wwn and rownum = 1)
group by
trunc(dw.mdf_date)
,dw.dss_id
,dw.raid
,dw.host_type
,dw.volume_name
,dw.volume_size
,dw.prv
此请求持续23秒。 如果您注释掉这一行,那将可以快速运行0.2秒
and not exists (select 1 from wwn shw where shw.wwn = dw.hba_wwn and shw.dic_type_eqp_id = 4 and rownum = 1)
select count(*) from DSS_WWN --100000
select count(*) from WWN t --13000
UPD @Gro感谢您的回答,确实是在我删除rownum = 1请求后,它在0.4秒内完成了