select /*+parallet(t_base_user_buy_info,4)*/ a.f_yearweek,a.f_lotbigclass,b.expenum,a.salay,b.countrysalay,a.bonus,b.countrybonus
from (
select to_char(b.f_date,'yyyymmww') as f_yearweek,c.f_lotbigclass,f_flatname,
sum(f_buymoney) salay,
sum(f_taxbefforbonus) bonus
from t_base_user_buy_info b
left join t_base_lot_send_bonus s
on b.f_lotid=s.f_lotid and s.f_wtype=b.f_wtype and s.f_expect=b.f_expect
inner join t_base_flat_type t
on t.f_buymodename=b.f_buychannel and t.f_department=1 and f_flatname='主站'
inner join ( select distinct f_lotbigclass,f_lottype from t_base_lotclass t where f_classsort=1) c
on b.f_lotid=c.f_lottype
where b.f_date between to_date('2007-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2007-01-10 00:00:00','yyyy-mm-dd hh24:mi:ss')
and s.f_date between to_date('2007-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2007-01-10 00:00:00','yyyy-mm-dd hh24:mi:ss')
group by to_char(b.f_date,'yyyymmww'),c.f_lotbigclass,f_flatname
) a inner join (
select to_char(b.f_date,'yyyymmww') as f_yearweek,c.f_lotbigclass,
count(distinct b.f_expect) expenum,
sum(b.f_buymoney) countrysalay,
sum(s.f_taxbefforbonus) countrybonus
from t_base_user_buy_info b
left join t_base_lot_send_bonus s
on b.f_lotid=s.f_lotid and s.f_wtype=b.f_wtype and s.f_expect=b.f_expect
inner join t_base_flat_type t
on t.f_buymodename=b.f_buychannel and t.f_department=1
inner join ( select distinct f_lotbigclass,f_lottype from t_base_lotclass t where f_classsort=1) c
on b.f_lotid=c.f_lottype
where b.f_date between to_date('2007-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2007-01-10 00:00:00','yyyy-mm-dd hh24:mi:ss')
and s.f_date between to_date('2007-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2007-01-10 00:00:00','yyyy-mm-dd hh24:mi:ss')
group by to_char(b.f_date,'yyyymmww'),c.f_lotbigclass,f_flatname
) b on a.f_yearweek=b.f_yearweek and a.f_lotbigclass=b.f_lotbigclass ;
執行計畫
最後把兩個大表現統計後在left join 那樣佔臨時表空間就少了
select a.f_yearweek,c.f_lotbigclass,sum(expenum) expenum ,sum(countrysalay) countrysalay,sum(countrybonus) countrybonus
from
(select to_char(f_date,'yyyymmww') as f_yearweek ,f_lotid, count(distinct f_expect) expenum, sum(f_buymoney) countrysalay
from t_base_user_buy_info
where f_date between to_date('2007-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2007-01-10 00:00:00','yyyy-mm-dd hh24:mi:ss')
group by to_char(f_date,'yyyymmww'),f_lotid
) aleft join
(select to_char(f_date,'yyyymmww') as f_yearweek ,f_lotid,sum(f_taxbefforbonus) countrybonus
from t_base_lot_send_bonus
where f_date between to_date('2007-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2007-01-10 00:00:00','yyyy-mm-dd hh24:mi:ss')
group by to_char(f_date,'yyyymmww'),f_lotid
)b on a.f_yearweek=b.f_yearweek and a.f_lotid=b.f_lotid
inner join
(select distinct f_lottype,f_lotbigclass
from t_base_lotclass
where f_classsort=1
)c on a.f_lotid=c.f_lottype
group by a.f_yearweek,c.f_lotbigclass
select a.f_yearweek,a.f_lotbigclass,expenum ,locatesalay,countrybonus
from
(select to_char(f_date,'yyyymmww') as f_yearweek ,f_lotbigclass,
count(distinct f_expect) expenum, sum(f_buymoney) locatesalay
from t_base_user_buy_info
inner join t_base_flat_type t on f_buymodename=f_buychannel and f_department=1 and f_flatname='主站'
inner join ( select distinct f_lotbigclass,f_lottype from t_base_lotclass t where f_classsort=1) c
on f_lotid=c.f_lottype
where f_date between to_date('2007-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2007-01-10 00:00:00','yyyy-mm-dd hh24:mi:ss')
group by to_char(f_date,'yyyymmww'),f_lotbigclass
) aleft join
(select to_char(f_date,'yyyymmww') as f_yearweek ,f_lotbigclass,sum(f_taxbefforbonus) countrybonus
from t_base_lot_send_bonus s
inner join t_base_flat_type t on s.f_buymodeid=t.f_buymodeid and f_department=1 and f_flatname='主站'
inner join ( select distinct f_lotbigclass,f_lottype from t_base_lotclass t where f_classsort=1) c
on f_lotid=c.f_lottype
where f_date between to_date('2007-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2007-01-10 00:00:00','yyyy-mm-dd hh24:mi:ss')
group by to_char(f_date,'yyyymmww'),f_lotbigclass
)b on a.f_yearweek=b.f_yearweek and a.f_lotbigclass=b.f_lotbigclass
如何處理Oracle中TEMP表空間滿的問題
正常來說,在完成select語句 create index等一些使用temp表空間的排序操作後,oracle是會自動釋放掉臨時段a的。但有些有侯我們則會遇到臨時段沒有被釋放,temp表空間幾乎 滿的狀況,甚至是我們重啟了資料庫仍沒有解決問題。這個問題在論壇中也常被問到,下面我總結一下,給出幾種處理方...
如何處理Oracle中TEMP表空間滿的問題?
正常來說,在完成select語句 create index等一些使用temp 表空間的排序操作後,oracle 是會自動釋放掉臨時段a的。但有些有侯我們則會遇到臨時段沒有被釋放,temp 表空間幾乎滿的狀況,甚至是我們重啟了資料庫仍沒有解決問題。這個問題在論壇中也常被問到,下面我總結一下,給出幾種處...
如何處理Oracle中TEMP表空間滿的問題?
正常來說,在完成select語句 create index等一些使用temp表空間的排序操作後,oracle是會自動釋放掉臨時段a的。但有些有侯我們則會遇到臨時段沒有被釋放,temp表空間幾乎滿的狀況,甚至是我們重啟了資料庫仍沒有解決問題。方法一 重啟庫 庫重啟時,smon程序會完成臨時段釋放,te...