请问下面的SQL如何优化:
fx_deliverychecklist表2146949行,fx_accountdetails表3388132行
update fx_deliverychecklist a set a.checkscale=nvl(a.checkscale,0)+nvl((select b.checkscale from fx_accountdetails b where a.id=b.detailid and trim(a.deliveryid)=b.invoiceid and b.checkcash='F00006757'),0)
where exists
(select c.invoiceid from fx_accountdetails c where c.checkcash='F00006757' and trim(a.deliveryid)=c.invoiceid)

解决方案 »

  1.   

    update fx_deliverychecklist a 
      set a.checkscale=nvl(a.checkscale,0)+(select nvl(b.checkscale,0) 
      from fx_accountdetails b 
     where b.detailid = a.id 
       and b.checkcash = 'F00006757'
       and b.invoiceid = trim(a.deliveryid) )
    where exists
    ( select 1 from fx_accountdetails c 
       where c.detailid = a.id
         and c.checkcash='F00006757' 
         and trim(a.deliveryid)=c.invoiceid);-- 好像没有优化的余地啦...........
      

  2.   

    update fx_deliverychecklist a 
      set a.checkscale=nvl(a.checkscale,0)+(select nvl(b.checkscale,0) 
                          from fx_accountdetails b 
                         where b.detailid = a.id 
                           and b.checkcash = 'F00006757'
                           and b.invoiceid = trim(a.deliveryid) )
    where exists
    ( select 1 from fx_accountdetails c 
       where c.detailid = a.id
         and c.checkcash = 'F00006757' 
         and c.invoiceid = trim(a.deliveryid));