有两张表分别是:bill_call_rec 7万记录,subr_info 1万5条记录
现在使用下面select时候,特别慢,要10多分钟
CODE:
select round(sum(a.call_dur)/60)
from bill_call_rec a
, subr_info b
where a.breakdown_cd = 'LOCAL'
and a.call_start_date >= to_date('0101'||to_char(add_months(sysdate,-12),'yyyy'),'ddmmyyyy')
and a.call_start_date < to_date('0101'||to_char(sysdate,'yyyy'),'ddmmyyyy')
and (
a.dialed_digits <> b.subr_num
or (a.dialed_digits = b.subr_num
and a.call_start_date not between b.subr_sw_on_date and b.subr_sw_off_date
) 请问该如何优化?
主要问题是执行:
a.dialed_digits <> b.subr_num
和
a.dialed_digits = b.subr_num
and a.call_start_date not between b.subr_sw_on_date and b.subr_sw_off_date
时候特别耗时间。
谢谢
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/640706/viewspace-506153/,如需转载,请注明出处,否则将追究法律责任。