大家好,我正在寻找优化这个SQL脚本的方法,以获得更好的性能,有谁可以帮助我吗
With accounts As
(
select account_id, creation_date
from account
where program_distributor = 'brinks'
and channel = 'online'
and creation_year = 2017
),
Form_opens as
(
select session_id, log_time
from web_action_log
where web_action = 'open_dd_form'
),
Mapping as
(
select session_id, account_id
from web_link
)
Select
trunc (acc.creation_date),
count(distinct acc.account_id),
count (distinct fo.account_id)
from accounts acc
left outer join mapping mp
on acc.account_id = mp.account_id
Left outer join form_opens fo
on mo.session_id = fo.session_id and
acc.creation_date > do.log_time
Group by trunc(acc.creation_date)
Order by 1;发布于 2018-03-23 15:28:12
在下面尝试,query.You可以跳过with子句的编写,因为您没有多次查询with子句输出表。在联接过程中添加筛选条件也可以提高性能。
select
trunc (acc.creation_date),
count(distinct acc.account_id),
count (distinct fo.account_id)
from account acc
left outer join web_link mp
on acc.account_id = mp.account_id
left outer join web_action_log fo
on mo.session_id = fo.session_id
and acc.creation_date > fo.log_time
and fo.web_action = 'open_dd_form'
where acc.program_distributor = 'brinks'
and acc.channel = 'online'
and acc.creation_year = 2017
group by trunc(acc.creation_date)
order by 1;https://stackoverflow.com/questions/49442643
复制相似问题