SSISO Community

시소당

group by를 온라인 부분 범위 처리로 유도

온라인으로  대량의  데이터를  조회하여  보고자  하는  경우에  부분범위를  유도하여  성능을  
향상시킴.
고객정보(영업지점,  기준일이  조건절에  들어왔을  때)  계좌별  일일  잔고(잔액의  합계  
sum(b.cul_bal)이  입력된  기준금액(:ismbal)  이상인  고객의  리스트를  구한다.

select  a.cust_name,  sum(b,cul_bal)
from  cmf_cust,  wdda_acc  b
where  a.id_no  =  b.id_no
and  a.br_cd  =  :brcd  and  b.gijun_il  =  :idate
group  by  a.cust_name
having  sum(b.cul_bal)  >=  :isumbal    

(개선안)
select  a.cust_name,  get_sum(A.ID_NO,  :IDATE)
from  icmf_cust  a  
where  a.br_cd  =  :ibrcd
and  :isumbal  <=  
(select  sum(cul_bal)  from  wdda_acct  b  where  a.id_no  =  b.id_no  and  b.gijun_il  =  :idate);

Create  or  replace  function  get_sum(vidno  in  number,  vidate  in  date)
Return  number
Is
Sum_bal  number;
Begin
          Select  sum(cul_bal)  into  sum_bal
              From  wdda_acct
          Where  id_no  =  vidno
                And  gijun_il  =  vidate;
            Return  sum_bal;
End;  

972 view

4.0 stars