0
create materialized view MV_SD_SIPL_BOMLEVELSALT_5 refresh force on demand as 
(
select 'id-' || rownum id, 
                t1.L1 l0, t1.L0 l1, t1.alternateitem l1ai, t1.effstartdate l1sd, t1.effenddate l1ed, t1.qtyper l1q, t1.siteid l1s, t1.transittime l1tt,
                t2.l0 l2,  t2.alternateitem l2ai, t2.effstartdate l2sd, t2.effenddate l2ed, t2.qtyper l2q, t2.siteid l2s, t2.transittime l2tt,
                t3.l0 l3,  t3.alternateitem l3ai, t3.effstartdate l3sd, t3.effenddate l3ed, t3.qtyper l3q, t3.siteid l3s,t3.transittime l3tt,
                t4.l0 l4, t4.alternateitem l4ai, t4.effstartdate l4sd, t4.effenddate l4ed, t4.qtyper l4q, t4.siteid l4s,t4.transittime l4tt,
                t5.l0 l5, t5.alternateitem l5ai, t5.effstartdate l5sd, t5.effenddate l5ed, t5.qtyper l5q, t5.siteid l5s,t5.transittime l5tt,
                t6.l0 l6, t6.alternateitem l6ai, t6.effstartdate l6sd, t6.effenddate l6ed, t6.qtyper l6q, t6.siteid l6s,t6.transittime l6tt,
                t7.l0 l7, t7.alternateitem l7ai, t7.effstartdate l7sd, t7.effenddate l7ed, t7.qtyper l7q, t7.siteid l7s,t7.transittime l7tt,
                t8.l0 l8, t8.alternateitem l8ai, t8.effstartdate l8sd, t8.effenddate l8ed, t8.qtyper l8q, t8.siteid l8s,t8.transittime l8tt,
                t9.l0 l9, t9.alternateitem l9ai, t9.effstartdate l9sd, t9.effenddate l9ed, t9.qtyper l9q, t9.siteid l9s,t9.transittime l9tt,
                t10.l0 l10, t10.alternateitem l10ai, t10.effstartdate l10sd, t10.effenddate l10ed, t10.qtyper l10q, t10.siteid l10s,t10.transittime l10tt,
                t11.l0 l11, t11.alternateitem l11ai, t11.effstartdate l11sd, t11.effenddate l11ed, t11.qtyper l11q, t11.siteid l11s,t11.transittime l11tt,
                nvl2(t1.L0, 1, 0) + nvl2(t1.L0, 1, 0) + nvl2(t2.l0, 1, 0) +
                nvl2(t3.l0, 1, 0) + nvl2(t4.l0, 1, 0) + nvl2(t5.l0, 1, 0) +
                nvl2(t6.l0, 1, 0) + nvl2(t7.l0, 1, 0) + nvl2(t8.l0, 1, 0) +
                nvl2(t9.l0, 1, 0) + nvl2(t10.l0, 1, 0) + nvl2(t11.l0, 1, 0) cnt,
                t1.l1 sku,
                t1.bomid
  from (select L1, L0, alternateitem,effstartdate,effenddate, qtyper,siteid,fromsiteid,bomid,
   transittime  from MV_SD_SIPL_BOMLEVELSALT55 where l1 like 'SD%') t1
  left outer join MV_SD_SIPL_BOMLEVELSALT55 t2 on t1.alternateitem = t2.l1 and t1.fromsiteid = t2.siteid
  left outer join MV_SD_SIPL_BOMLEVELSALT55 t3 on t2.alternateitem = t3.l1 and t2.fromsiteid = t3.siteid
  left outer join MV_SD_SIPL_BOMLEVELSALT55 t4 on t3.alternateitem = t4.l1 and t3.fromsiteid = t4.siteid
  left outer join MV_SD_SIPL_BOMLEVELSALT55 t5 on t4.alternateitem = t5.l1 and t4.fromsiteid = t5.siteid
  left outer join MV_SD_SIPL_BOMLEVELSALT55 t6 on t5.alternateitem = t6.l1 and t5.fromsiteid = t6.siteid
  left outer join MV_SD_SIPL_BOMLEVELSALT55 t7 on t6.alternateitem = t7.l1 and t6.fromsiteid = t7.siteid
  left outer join MV_SD_SIPL_BOMLEVELSALT55 t8 on t7.alternateitem = t8.l1 and t7.fromsiteid = t8.siteid
  left outer join MV_SD_SIPL_BOMLEVELSALT55 t9 on t8.alternateitem = t9.l1 and t8.fromsiteid = t9.siteid
  left outer join MV_SD_SIPL_BOMLEVELSALT55 t10 on t9.alternateitem = t10.l1 and t9.fromsiteid = t10.siteid
  left outer join MV_SD_SIPL_BOMLEVELSALT55 t11 on t10.alternateitem = t11.l1 and t10.fromsiteid = t11.siteid
);

マテリアライズド ビューを作成する上記のクエリがあり、完了するまでに約 50 分かかります。タイミングを減らすのを手伝ってください..通常のインデックスを作成しようとし、クエリを書き直そうとしましたが、役に立ちませんでした。Explain Plan が添付されています。クエリの調整を手伝ってください。ありがとう

4

1 に答える 1

1

最初のポイント

あなたが言ったとき

通常のインデックスを作成してみました

どういう意味?作成したインデックスを見せてもらえますか? あなたが忘れたインデックスがあると確信しています。インデックスが必要な列のリスト:

l1, alternateitem, fromsiteid, and siteid

2 点目

これは悪いです:

from 
(
    select L1, L0, alternateitem,effstartdate,effenddate, qtyper,siteid,fromsiteid,bomid, transittime  
    from MV_SD_SIPL_BOMLEVELSALT55 
    where l1 like 'SD%'
) t1

なぜここでサブクエリを作成しているのですか? 句をフィルタリングするだけです:

select  bablabla
from MV_SD_SIPL_BOMLEVELSALT55 as t1
    left outer join blablabla
where t1.l1 like 'SD%'
于 2013-04-18T09:02:01.010 に答える