SQL查询执行时间长

SQL查询执行时间长,sql,oracle,performance,oracle11g,query-optimization,Sql,Oracle,Performance,Oracle11g,Query Optimization,我正在尝试执行下面的查询,执行起来需要很长时间。我是否可以在下面的查询中进行更改?执行需要60多分钟,有时甚至会被绞死 select distinct z.por_s as Portfolio_Number,z.lse_s as Account_Number,y.les_s as Lessee_Number,z.unit_S as Asset,to_char(x.d_com_s, 'MM/DD/YYYY') as Start_Date, to_char(x.d_mat_s,'MM/DD/YY

我正在尝试执行下面的查询,执行起来需要很长时间。我是否可以在下面的查询中进行更改?执行需要60多分钟,有时甚至会被绞死

select distinct z.por_s as Portfolio_Number,z.lse_s as 
Account_Number,y.les_s as Lessee_Number,z.unit_S as Asset,to_char(x.d_com_s, 
'MM/DD/YYYY') as Start_Date, to_char(x.d_mat_s,'MM/DD/YYYY') as 
Maturity_Date, x.p_con_d as Yield,k.nam_long_s as Venodr_Name,z.dlr_s as 
Venodr_Number,y.client_s_name_s as Customer_Name,y.short_add_s as 
Billing_Address,y.short_cty_s as City,y.st_s as State,z.eq_add_s as 
Equipment_Address, x.trm_l as Original_Term,(x.TRM_L - x.PMT_L) as 
Remaining_Term,z.id_S as EquipmentSerialID,z.org_d as Original_Amount, 
(NVL(x.lsd_unit_d, 0.0) - NVL(x.acl_depr_d, 0.0) - NVL(x.sec_d, 0.0) - 
NVL(SUM(b.bal_d), 0.0) + NVL(SUM(NVL(a.pamt_b_d, 0.0) + NVL(a.iamt_b_d, 0.0) 
- NVL(a.pamt_p_d, 0.0) - NVL(a.iamt_p_d, 0.0)), 0.0) - NVL(x.op_bill_adj_d, 
0.0) + NVL(x.unrec_in_d, 0.0)) as OPR_Remaining_Net_Investment,
(NVL(x.rec_d, 0.0) + NVL(SUM(NVL(d.aamt_b_d, 0.0) - NVL(d.aamt_p_d, 0.0)), 
0.0) +  NVL(SUM(NVL(a.pamt_b_d, 0.0) + NVL(a.iamt_b_d, 0.0) - 
NVL(a.pamt_p_d, 0.0) - NVL(a.iamt_p_d, 0.0)), 0.0) + NVL(x.tot_res_d, 0.0) - 
NVL(x.res_guar_d, 0.0) - NVL(x.l_ue_d, 0.0) + NVL(x.r_ue_d, 0.0) + 
NVL(x.i_ue_d, 0.0) + NVL(x.d_ue_d, 0.0) + NVL(x.l_in_ptd_d, 0.0) + 
NVL(x.r_in_ptd_d, 0.0) + NVL(x.i_in_ptd_d, 0.0) + NVL(x.d_in_ptd_d, 0.0) - 
NVL(x.sec_d, 0.0) - NVL(SUM(b.bal_d), 0.0) - NVL(x.susp_l_acc_d, 0.0) + 
NVL(x.susp_r_acc_d, 0.0) + NVL(x.susp_d_acc_d, 0.0) + NVL(x.susp_i_acc_d, 
0.0)) as PRE_Remaining_Net_Investment
,z.res_d as Residual_Asset ,n.bus_phn_s as Business_Phone, n.hom_phn_s as 
Home_phone,o.field19_s as Credit_Guarantee, o.field20_s as 
Residual_Guarantee,m.add_s as Guarantor_Address,m.add2_s as 
Guarantor_Address2,m.cty_s as Guarantor_City,m.st_s as 
Guarantor_State,m.zip_s as Guarantor_Zip
from rgc c 
FULL join rls x on c.APP_LSE_S = x.LSE_S
FULL Join rar a on x.LSE_S = a.LSE_S
FULL Join rsu b on x.LSE_S = b.LSE_S
FULL Join rarb d on x.por_s = d.por_s
FULL join vrcx_les y on x.les_s = y.les_s
FULL join req z on x.LSE_S = z.LSE_S
FULL join rlr k on z.dlr_s = k.dlr_s
FULL join ral n on x.les_s = n.les_s
FULL join rug o on x.lse_s = o.lse_s
FULL JOIN RGR m ON c.CLIENT_ID_S = m.GRN_S 
where x.act_s in ('AACQ', 'AASM', 'AEXM', 'ANOR', 'ARBK', 'ARED', 'AREN', 
'AXFR') and x.d_mat_s > to_date ('07/01/2018', 'MM/DD/YYYY')
and a.por_s = x.por_s
AND a.com_s = x.com_s
AND a.reg_s = x.reg_s
AND a.off_s = x.off_s
AND a.lse_s = x.lse_s
AND d.invo_s = a.invo_s
AND d.a_typ_s in ('PROR', 'IDR2', 'SECD')
AND NVL(a.income_accrued_c, ' ') <> 'N'
group by z.por_s,z.lse_s,y.les_s,z.unit_S,x.d_com_s,
x.d_mat_s,x.p_con_d,k.nam_long_s,
z.dlr_s,y.client_s_name_s,y.short_add_s,
y.short_cty_s,y.st_s,z.eq_add_s,x.trm_l,x.PMT_L,  
z.id_S,z.org_d,x.lsd_unit_d,x.acl_depr_d,x.sec_d,
b.bal_d,a.pamt_b_d,a.iamt_b_d,a.pamt_p_d,a.iamt_p_d,
x.op_bill_adj_d,x.unrec_in_d,x.rec_d,x.res_guar_d,
d.aamt_b_d,d.aamt_p_d,a.pamt_b_d,a.iamt_b_d,a.pamt_p_d,  
a.iamt_p_d,x.tot_res_d,x.res_guar_d,x.l_ue_d,x.r_ue_d,
x.i_ue_d,x.d_ue_d,x.l_in_ptd_d,x.r_in_ptd_d,x.i_in_ptd_d,
x.d_in_ptd_d,x.susp_l_acc_d,x.susp_r_acc_d,x.susp_d_acc_d,
x.susp_i_acc_d,z.res_d,n.bus_phn_s,n.hom_phn_s,o.field19_s,
o.field20_s,m.add_s,m.add2_s,m.cty_s,m.st_s,m.zip_s;
选择不同的z.por作为投资组合编号,z.lse作为
账户编号,y.les作为承租人编号,z.unit作为资产,至,
“MM/DD/YYYY”)作为开始日期,改为字符(x.d\u mat\s,'MM/DD/YYYY')作为开始日期
到期日,x.p_con_d为收益率,k.nam_long_s为Venodr_名称,z.dlr_s为
Venodr_编号,y.客户名称作为客户名称,y.简短名称作为添加
账单地址,y.short作为城市,y.st作为州,z.eq作为添加
设备地址,x.trm\u l作为原始术语,(x.trm\u l-x.PMT\u l)作为
剩余期限,z.id作为设备序列id,z.org作为原始金额,
(NVL(x.lsd_单位,0.0)-NVL(x.acl_单位,0.0)-NVL(x.sec_单位,0.0)-
NVL(总和(b.bal\U d),0.0)+NVL(总和(NVL(a.pamt_UB_UD,0.0)+NVL(a.iamt_UB_UD,0.0)
-NVL(a.pamt_p_d,0.0)-NVL(a.iamt_p_d,0.0)),0.0)-NVL(x.op_bill_adj,
0.0)+NVL(x.unrec\u in\u d,0.0))作为运营剩余净投资,
(NVL(x.rec_d,0.0)+NVL(总和)(NVL(d.aamt_b_d,0.0)-NVL(d.aamt_p_d,0.0)),
0.0)+NVL(总和)(NVL(a.pamt_b_d,0.0)+NVL(a.iamt_b_d,0.0)-
NVL(a.pamt_p_d,0.0)-NVL(a.iamt_p_d,0.0)),0.0)+NVL(x.tot_resu d,0.0)-
NVL(x.res_-guar_-d,0.0)-NVL(x.l_-ue_-d,0.0)+NVL(x.r_-ue-d,0.0)+
NVL(x.i____d,0.0)+NVL(x.d___d,0.0)+NVL(x.l_in_ptd_d,0.0)+
NVL(x.r_in_ptd_d,0.0)+NVL(x.i_in_ptd_d,0.0)+NVL(x.d_in_ptd_d,0.0)-
NVL(x.secu_d,0.0)-NVL(SUM(b.bal_d,0.0)-NVL(x.sus_l_acc_d,0.0)+
NVL(x.susp_r_acc_d,0.0)+NVL(x.susp_d_acc_d,0.0)+NVL(x.susp_i_acc_d,
0.0)作为前期剩余净投资
,z.RESU d作为剩余资产,n.bus作为业务电话,n.hom作为phn
家用电话,o.field19作为信用担保,o.field20作为信用担保
剩余担保,m.add作为担保人地址,m.add2作为担保人地址
担保人地址2,m.cty作为担保人城市,m.st作为担保人城市
担保人州,m.zip作为担保人
研资局
c.APP_LSE_S=x.LSE_S上的完全连接rls x
x.LSE_S=a.LSE_S上的完全联接rar a
x.LSE_S=b.LSE_S上的完全联接rsu b
x.por\u s=d.por\u s上的完全联接rarb d
x.les\u s=y.les\u s上的完全联接vrcx\u les y
x.LSE_S=z.LSE_S上的完全连接请求z
z.dlr_s=k.dlr_s上的完全连接rlr k
x.les\u s=n.les\u s上的完全连接ral n
x.lse_s=o.lse_s上的完全连接地毯o
c.CLIENT\u ID\u S=m.GRN\u S上的完全连接RGR m
其中x.act_s in('AACQ','AASM','AEXM','ANOR','ARBK','ARED','AREN',
“AXFR”)和x.d材料截至日期(“2018年1月7日”、“年/月/日”)
a.por_s=x.por_s
a.com_s=x.com_s
a.reg_s=x.reg_s
a.off_s=x.off_s
a.lse_s=x.lse_s
和d.invo_s=a.invo_s
和d.a_类型('PROR'、'IDR2'、'SECD')
和NVL(a.应计收入(c)‘’)‘N’
由z.por_s、z.lse_s、y.les_s、z.unit_s、x.d_com_s、,
x、 d_mat_s,x.p_con_d,k.nam_long_s,
z、 dlr_s,y.客户_s_姓名_s,y.简短_添加_s,
y、 短的,y.st,z.eq,add,x.trm,x.PMT,
z、 id\u S,z.org\u d,x.lsd\u unit\u d,x.acl\u depr\u d,x.sec\u d,
b、 bal_d,a.pamt_b_d,a.iamt_b_d,a.pamt_p_d,a.iamt_p_d,
x、 op_bill_adj_d,x.unrec_in_d,x.rec_d,x.res_guar d,
d、 啊,啊,啊,啊,啊,啊,啊,啊,啊,啊,啊,啊,啊,
a、 我的,我的,我的,我的,我的,我的,我的,
x、 i______d,x.d__d,x.l_in_ptd_d,x.r_in_ptd_d,x.i_in_ptd_d,
x、 d_in_ptd_d,x.susp_l_acc_d,x.susp_r_acc_d,x.susp_d acc_d,
x、 Suss_i_acc_d,z.Resu d,n.bus_phn_s,n.hom_phn_s,o.field19_s,
o、 字段20_s、m.add_s、m.add2_s、m.cty_s、m.st_s、m.zip_s;
需要对此查询进行任何更改,请帮助我解决此问题。

选择distinct z.por\u s作为公文包编号,
    select distinct z.por_s as Portfolio_Number,
    z.lse_s as Account_Number,
    ...

    from rgc c 
    FULL join rls x on c.APP_LSE_S = x.LSE_S #match nro account (1)
    FULL Join rar a on x.LSE_S = a.LSE_S #match nro account (2)
    FULL Join rsu b on x.LSE_S = b.LSE_S #match nro account (3)
    FULL Join rarb d     on x.por_s = d.por_s  #match (4)
    FULL join vrcx_les y on x.les_s = y.les_s #match nro less
    FULL join req z      on x.LSE_S = z.LSE_S #match nro account

    FULL join rlr k on z.dlr_s = k.dlr_s

    FULL join ral n on x.les_s = n.les_s #match nro less
    FULL join rug o on x.lse_s = o.lse_s #match nro account

    FULL JOIN RGR m ON c.CLIENT_ID_S = m.GRN_S 
    where x.act_s in 
    ('AACQ', 'AASM', 'AEXM', 'ANOR', 'ARBK', 'ARED', 'AREN', 'AXFR')  #use this in the full join (2)
    and x.d_mat_s > to_date ('07/01/2018', 'MM/DD/YYYY') #use this in the full join (2)
    and a.por_s = x.por_s #use this in the full join (2)
    AND a.com_s = x.com_s #use this in the full join (2)
    AND a.reg_s = x.reg_s #use this in the full join (2)
    AND a.off_s = x.off_s  #use this in the full join (2)
    AND a.lse_s = x.lse_s #use this in the full join (2)
    AND d.invo_s = a.invo_s  #use this in the full join (4)
    AND d.a_typ_s in ('PROR', 'IDR2', 'SECD')
    AND NVL(a.income_accrued_c, ' ') <> 'N' #nvl is not necesary
    group by z.por_s,z.lse_s,y.les_s,z.unit_S,x.d_com_s,
    ...
z、 lse作为账号, ... 研资局 完全加入c.APP上的rls x\u LSE\u S=x.LSE\u S#匹配nro帐户(1) 完全加入x.LSE_S=a.LSE_S#匹配nro帐户上的rar a(2) 完全加入x.LSE_S=b.LSE_S#匹配nro帐户上的rsu b(3) x.por_s=d.por_s#match(4)上的完全联接rarb d x.les_s=y.les_s#match nro less上的完全联接vrcx_les y x.LSE_S=z.LSE_S#匹配nro帐户上的完全加入请求z z.dlr_s=k.dlr_s上的完全连接rlr k x.les_s=n.les_s#match nro less上的完全联接ral n x.lse_s=o.lse_s#匹配nro帐户上的完全加入rug o c.CLIENT\u ID\u S=m.GRN\u S上的完全连接RGR m x.act_在哪里 ('AACQ','AASM','AEXM','ANOR','ARBK','ARED','AREN','AXFR')#在完全联接中使用此选项(2) 和x.d_mat_s>截止日期('2018年1月7日','MM/DD/YYYY')#在完全联接中使用此选项(2) a.por_s=x.por_s#在完全联接中使用此选项(2) a.com_s=x.com_s#在完全联接中使用此选项(2) a.reg_s=x.reg_s#在完全联接中使用此选项(2) a.off_s=x.off_s#在完全联接中使用此选项(2) a.lse_s=x.lse_s#在完全联接中使用此选项(2) 和d.invo_s=a.invo_s#在完全联接中使用此选项(4) 和d.a_类型('PROR'、'IDR2'、'SECD') 和NVL(a.应计收入,)“N”#NVL不是必需的 由z.por_s、z.lse_s、y.les_s、z.unit_s、x.d_com_s、, ...
我会在连接中设置限制,这样就不会合并所有行(例如1000 x 1000),只合并需要的行(100 x 1000),如下所示:

 from rgc c 
    FULL join rls x on c.APP_LSE_S = x.LSE_S #match nro account (1)
    FULL Join rar a on x.LSE_S = a.LSE_S #match nro account (2)
    and x.act_s in 
    ('AACQ', 'AASM', 'AEXM', 'ANOR', 'ARBK', 'ARED', 'AREN', 'AXFR')  #use this in the full join (2)
    and x.d_mat_s > to_date ('07/01/2018', 'MM/DD/YYYY') #use this in the full join (2)
    and a.por_s = x.por_s #use this in the full join (2)
    AND a.com_s = x.com_s #use this in the full join (2)
    AND a.reg_s = x.reg_s #use this in the full join (2)
    AND a.off_s = x.off_s  #use this in the full join (2)
    AND a.lse_s = x.lse_s #use this in the full join (2)
    AND a.income_accrued_c <> 'N' #nvl is not necesary, if its null its <> from 'N'

    FULL Join rsu b on x.LSE_S = b.LSE_S #match nro account (3)
    FULL Join rarb d     on x.por_s = d.por_s  #match (4)
     and d.invo_s = a.invo_s  #use this in the full join (4)
     AND d.a_typ_s in ('PROR', 'IDR2', 'SECD')
    FULL join vrcx_les y on x.les_s = y.les_s #match nro less
    FULL join req z      on x.LSE_S = z.LSE_S #match nro account

    FULL join rlr k on z.dlr_s = k.dlr_s

    FULL join ral n on x.les_s = n.les_s #match nro less
    FULL join rug o on x.lse_s = o.lse_s #match nro account

    FULL JOIN RGR m ON c.CLIENT_ID_S = m.GRN_S 
 where 1=1
 group by ....
来自rgc的

完全加入c.APP上的rls x\u LSE\u S=x.LSE\u S#匹配nro帐户(1)
完全加入x.LSE_S=a.LSE_S#匹配nro帐户上的rar a(2)
和x.act_s in
('AACQ','AASM','AEXM','ANOR','ARBK','ARED','AREN','AXFR')#在完全联接中使用此选项(2)
和x.d_mat_s>截止日期('2018年1月7日','MM/DD/YYYY')#在完全联接中使用此选项(2)
a.por_s=x.por_s#在完全联接中使用此选项(2)
a.com_s=x.com_s#在完全联接中使用此选项(2)
a.reg_s=x.reg_s#在完全联接中使用此选项(2)
a.off_s=x.off_s#在完全联接中使用此选项(2)
a.lse_s=x.lse_s#在完全联接中使用此选项(2)
而a.income_Accounted_c'N'#nvl不需要,如果它从'N'开始为空
完全加入x.LSE_S=b.LSE_S#匹配nro帐户上的rsu b(3)
x.por_s=d.por_s#match(4)上的完全联接rarb d
d.invo_s=a.invo_s#在t中使用这个