|
|
有张表600多万的数据cust_a, 400多万的cust_b.
create table cust_a
( brand_type_cd varchar2(20) not null,
touch_daily_no char(15) not null,
touch_date char(8),
corner_no char(10),
touch_object_type_cd varchar2(20),
from_choice_date char(8),
to_choice_date char(8),
choice_id varchar2(20),
touch_deadline_yn char(1));
create table cust_b
( brand_type_cd varchar2(20) not null,
touch_daily_no char(15) not null,
cust_no char(10) not null);
create table corner_info
( corner_no char(10) not null,
brand_type_cd varchar2(20) not null,
available_end_date char(8) not null,
corner_name varchar2(50));
create table sys_master_code
( master_cd varchar2(20) not null,
cd_name1 varchar2(200),
parent_cd varchar2(20),
display_order number,
active char(1));
====================================================================
select master_cd, cd_name1,touch_daily_no,nvl(count,0) count
from (
select d.touch_daily_no, touch_object_type_cd, count(cust_no) count
from cust_a d, cust_b o, corner_info c
where
c.corner_no = d.corner_no
and c.brand_type_cd = d.brand_type_cd
and c.brand_type_cd = 'BRAND_CD_OHUI'
and d.touch_daily_no = o.touch_daily_no
and available_end_date = '99990101'
and from_choice_date = to_char(sysdate,'YYYYMMDD')
group by touch_object_type_cd, d.touch_daily_no
) a,
(select master_cd, cd_name1
from sys_master_code
where parent_cd = 'TOUCH_OBJ_TYPE_CD' and active = 'Y' ) b
where b.master_cd = touch_object_type_cd(+)
这个SQL要1分半才出结果,谁能帮忙优化一下?多谢各位高手! |
|