Oracle資料庫遠算量較大 會出現幾分鐘后才出資料
應該怎么優化呢 大佬們
運算量主要大在會有 上千條甚至上萬條資料 加和 處理 而且加和不止一次 明天我拍一下sql 求大家幫忙 看看這個問題
uj5u.com熱心網友回復:
具體問題具體分析,你要提供SQL跟大概的表說明才能幫到你哦uj5u.com熱心網友回復:
嗯嗯 明天我拍一下sqluj5u.com熱心網友回復:
這個是sql有點長 我發下 大家幫幫忙 麻煩大家了uj5u.com熱心網友回復:
select b.branchname branchName,c.branchname supebranchName,a.branchnum branchNum,m.deviceSum,o.runningDays1*m.deviceSum,o.runningDays1 runningDays,decode(o.runningDays1*m.deviceSum,0,0,round((nvl(h.transferNum,0)+nvl(i.OPENCARDNUM,0)+nvl(d.PASSWORDNUM,0)+nvl(e.PERSONINFONUM,0)+nvl(f.PRINTNUM,0)+nvl(g.SIGNNUM,0)+nvl(j.CARDRELOSSNUM,0)+nvl(k.INTELLDEPOSITNUM,0)+nvl(l.FINANCNUM,0)+nvl(n.LIVEPAYMENTNUM,0))/(o.runningDays1*m.deviceSum),1)) perDayDevNum,m.SUMDAYS,nvl(h.transferNum,0)+nvl(i.OPENCARDNUM,0)+nvl(d.PASSWORDNUM,0)+nvl(e.PERSONINFONUM,0)+nvl(f.PRINTNUM,0)+nvl(g.SIGNNUM,0)+nvl(j.CARDRELOSSNUM,0)+nvl(k.INTELLDEPOSITNUM,0)+nvl(l.FINANCNUM,0)+nvl(n.LIVEPAYMENTNUM,0) countNum,
decode(to_char(nvl(h.transferMoney,0)+nvl(k.INTELLDEPOSITMONEY,0)+nvl(l.FINANCMONEY,0),'fm99999999999999999990.0099999'),'.00','0',to_char(nvl(h.transferMoney,0)+nvl(k.INTELLDEPOSITMONEY,0)+nvl(l.FINANCMONEY,0),'fm99999999999999999990.0099999')) countMoney,
nvl(h.transferNum,0) transferNum,
decode(to_char(nvl(h.transferMoney,0),'fm99999999999999999990.0099999'),'.00','0',to_char(nvl(h.transferMoney,0),'fm99999999999999999990.0099999')) transferMoney,
nvl(k.INTELLDEPOSITNUM,0) INTELLDEPOSITNUM,
decode(to_char(nvl(k.INTELLDEPOSITMONEY,0),'fm99999999999999999990.0099999'),'.00','0',to_char(nvl(k.INTELLDEPOSITMONEY,0),'fm99999999999999999990.0099999')) INTELLDEPOSITMONEY,
nvl(l.FINANCNUM,0) FINANCNUM,
decode(to_char(nvl(l.FINANCMONEY,0),'fm99999999999999999990.0099999'),'.00','0',to_char(nvl(l.FINANCMONEY,0),'fm99999999999999999990.0099999')) FINANCMONEY,
nvl(n.LIVEPAYMENTNUM,0) LIVEPAYMENTNUM,
decode(to_char(nvl(n.LIVEPAYMENTMONEY,0),'fm99999999999999999990.0099999'),'.00','0',to_char(nvl(n.LIVEPAYMENTMONEY,0),'fm99999999999999999990.0099999')) LIVEPAYMENTMONEY,
nvl(i.OPENCARDNUM,0) openCardNum,nvl(d.PASSWORDNUM,0) passwordNum,nvl(e.PERSONINFONUM,0) personinfoNum,nvl(f.PRINTNUM,0) printNum,nvl(g.SIGNNUM,0) signNum,nvl(j.CARDRELOSSNUM,0) CARDRELOSSNUM from IB_LOG_LOGMASTER_LOG_BAK a
left join (select * from (select a.*,rownum ru from (select BranchNum from IB_UPM_BRANCH_INFO connect by nocycle prior BranchNum=SupeBranchNum start with BranchNum ='99999') a)) h on h.branchnum=a.BRANCHNUM
left join IB_UPM_BRANCH_INFO b on b.branchnum=a.BRANCHNUM
left join V_BRANCHINFO_VIEW c on b.SUPEBRANCHNUM=c.BRANCHNUM
left join (select count(BRANCHNUM) PASSWORDNUM,BRANCHNUM from IB_LOG_LOGMASTER_LOG_BAK where TRANCODE in ('pcva.trade.b036.01','pcva.trade.b082.01') and RETURNCODE='000000' and TRANDATE between '"+__REQ__["startTime"]+ "' and '"+__REQ__["endTime"]+ "'
and branchnum in (select branchnum from ib_upm_branch_info START WITH branchnum in ("+ __REQ__["branchId"] +") CONNECT BY PRIOR branchnum =supebranchnum) group by BRANCHNUM) d on d.BRANCHNUM=a.BRANCHNUM
left join (select count(BRANCHNUM) PERSONINFONUM,BRANCHNUM from IB_LOG_LOGMASTER_LOG_BAK
where TRANCODE = 'pcva.trade.b008.01' and RETURNCODE='000000' and TRANDATE between '"+__REQ__["startTime"]+ "' and '"+__REQ__["endTime"]+ "'
and branchnum in (select branchnum from ib_upm_branch_info START WITH branchnum in ("+ __REQ__["branchId"] +") CONNECT BY PRIOR branchnum =supebranchnum) group by BRANCHNUM) e on e.BRANCHNUM=a.BRANCHNUM
left join (select count(BRANCHNUM) PRINTNUM,BRANCHNUM from IB_LOG_LOGMASTER_LOG_BAK
where (TRANCODE in ('pcva.trade.b084.01','pcva.trade.b163.01') or OPRFLAG in ('D001','D002','B004') or (TRANCODE in ('pcva.trade.b207.01','pcva.trade.b214.01','pcva.trade.b216.01') and OPRTRANNAME in ('通知查詢/取消','通知建立'))) and RETURNCODE='000000' and TRANDATE between '"+__REQ__["startTime"]+ "' and '"+__REQ__["endTime"]+ "'
and branchnum in (select branchnum from ib_upm_branch_info START WITH branchnum in ("+ __REQ__["branchId"] +") CONNECT BY PRIOR branchnum =supebranchnum) group by BRANCHNUM) f on f.BRANCHNUM=a.BRANCHNUM
left join (select count(BRANCHNUM) SIGNNUM,BRANCHNUM from IB_LOG_LOGMASTER_LOG_BAK where (SIGNFLAG='S' or (TRANCODE='pcva.trade.b080.01' and RETURNCODE='000000')) and TRANDATE between '"+__REQ__["startTime"]+ "' and '"+__REQ__["endTime"]+ "'
and branchnum in (select branchnum from ib_upm_branch_info START WITH branchnum in ("+ __REQ__["branchId"] +") CONNECT BY PRIOR branchnum =supebranchnum) group by BRANCHNUM) g on g.BRANCHNUM=a.BRANCHNUM
left join (select sum(NUM) transferNum,sum(MONEY) transferMoney,BRANCHNUM FROM
((select count(BRANCHNUM) NUM,to_char(sum(AMOUNTMONEY),'fm99999999999999999990.0099999') MONEY,BRANCHNUM from IB_LOG_LOGMASTER_LOG_BAK where TRANCODE in ('pcva.trade.b216.01','pcva.trade.b215.01','pcva.trade.b214.01') and OPRTRANNAME in ('活期轉定期','定期轉活期') and RETURNCODE='000000' and TRANDATE between '"+__REQ__["startTime"]+ "' and '"+__REQ__["endTime"]+ "' and branchnum in (select branchnum from ib_upm_branch_info START WITH branchnum in ("+ __REQ__["branchId"] +") CONNECT BY PRIOR branchnum =supebranchnum) group by BRANCHNUM)
union
(select count(TFRAMT) NUM1,to_char(sum(TFRAMT),'fm99999999999999999990.0099999') MONEY1,BRNO BRANCHNUM from SS_CARD_TFRFLOW_INFO where RETURNCODE='000000' and TRANDT>='"+__REQ__["startTime"]+ "' and TRANDT<='"+__REQ__["endTime"]+ "' and BRNO in (select branchnum from ib_upm_branch_info START WITH branchnum in ("+ __REQ__["branchId"] +") CONNECT BY PRIOR branchnum =supebranchnum) group by BRNO)) GROUP BY BRANCHNUM) h on h.BRANCHNUM=a.BRANCHNUM
left join (select count(BRANCHNUM) OPENCARDNUM,BRANCHNUM from IB_LOG_LOGMASTER_LOG_BAK
where ((TRANCODE in ('pcva.trade.b087.01') or (TRANCODE='pcva.trade.b086.01' and OPRFLAG not in ('E') and OPRTRANNAME='二類戶系結/解綁') or OPENCARDFLAG='S') and RETURNCODE='000000')
and TRANDATE between '"+__REQ__["startTime"]+ "' and '"+__REQ__["endTime"]+ "'
and branchnum in (select branchnum from ib_upm_branch_info START WITH branchnum in ("+ __REQ__["branchId"] +") CONNECT BY PRIOR branchnum =supebranchnum) group by BRANCHNUM) i on i.BRANCHNUM=a.BRANCHNUM
left join (select count(BRANCHNUM) CARDRELOSSNUM,BRANCHNUM from IB_LOG_LOGMASTER_LOG_BAK where TRANCODE IN ('pcva.trade.b154.01','pcva.trade.b150.01','pcva.trade.b142.01') and TRANNAME not in ('卡書面掛失','卡密雙掛查詢') and RETURNCODE='000000' and TRANDATE between '"+__REQ__["startTime"]+ "' and '"+__REQ__["endTime"]+ "'
and branchnum in (select branchnum from ib_upm_branch_info START WITH branchnum in ("+ __REQ__["branchId"] +") CONNECT BY PRIOR branchnum =supebranchnum) group by BRANCHNUM) j on j.BRANCHNUM=a.BRANCHNUM
left join (select count(BRANCHNUM) INTELLDEPOSITNUM,to_char(sum(AMOUNTMONEY),'fm99999999999999999990.0099999') INTELLDEPOSITMONEY,BRANCHNUM from IB_LOG_LOGMASTER_LOG_BAK where TRANCODE IN ('pcva.trade.b201.01','pcva.trade.b203.01','pcva.trade.b204.01') and RETURNCODE='000000' and TRANDATE between '"+__REQ__["startTime"]+ "' and '"+__REQ__["endTime"]+ "'
and branchnum in (select branchnum from ib_upm_branch_info START WITH branchnum in ("+ __REQ__["branchId"] +") CONNECT BY PRIOR branchnum =supebranchnum) group by BRANCHNUM) k on k.BRANCHNUM=a.BRANCHNUM
left join (select count(BRANCHNUM) FINANCNUM,to_char(sum(AMOUNTMONEY),'fm99999999999999999990.0099999') FINANCMONEY,BRANCHNUM from IB_LOG_LOGMASTER_LOG_BAK where (TRANCODE IN ('pcva.trade.b044.01','pcva.trade.b206.01','pcva.trade.b046.01') or (TRANCODE='pcva.trade.b149.01' and OPRTRANNAME='理財風險評估')) and RETURNCODE='000000' and TRANDATE between '"+__REQ__["startTime"]+ "' and '"+__REQ__["endTime"]+ "'
and branchnum in (select branchnum from ib_upm_branch_info START WITH branchnum in ("+ __REQ__["branchId"] +") CONNECT BY PRIOR branchnum =supebranchnum) group by BRANCHNUM) l on l.BRANCHNUM=a.BRANCHNUM
left join (select BRANCHNUM,sum(runningDays) SUMDAYS,count(distinct DEVICENUM) deviceSum from (select a.DEVICENUM,a.BRANCHNUM,appnum,RETURNCODE,count(distinct a.TRANDATE) runningDays,TRANDATE FROM IB_LOG_LOGMASTER_LOG_BAK a where TRANDATE between '"+__REQ__["startTime"]+ "' and '"+__REQ__["endTime"]+ "' and branchnum in (select branchnum from ib_upm_branch_info START WITH branchnum in ("+ __REQ__["branchId"] +") CONNECT BY PRIOR branchnum =supebranchnum) and a.appnum='SS' and a.RETURNCODE='000000' group by DEVICENUM,BRANCHNUM,TRANDATE,appnum,RETURNCODE ) where TRANDATE between '"+__REQ__["startTime"]+ "' and '"+__REQ__["endTime"]+ "' and branchnum in (select branchnum from ib_upm_branch_info START WITH branchnum in ("+ __REQ__["branchId"] +") CONNECT BY PRIOR branchnum =supebranchnum) and appnum='SS' and RETURNCODE='000000' group by BRANCHNUM,appnum) m on m.BRANCHNUM=a.BRANCHNUM
left join (select count(BRANCHNUM) LIVEPAYMENTNUM,to_char(sum(AMOUNTMONEY),'fm99999999999999999990.0099999') LIVEPAYMENTMONEY,BRANCHNUM from IB_LOG_LOGMASTER_LOG_BAK where TRANCODE in ('pcva.trade.b167.01','pcva.trade.b237.01') and RETURNCODE='000000' and TRANDATE between '"+__REQ__["startTime"]+ "' and '"+__REQ__["endTime"]+ "'
and branchnum in (select branchnum from ib_upm_branch_info START WITH branchnum in ("+ __REQ__["branchId"] +") CONNECT BY PRIOR branchnum =supebranchnum) group by BRANCHNUM) n on n.BRANCHNUM=a.BRANCHNUM
left join (select to_date('"+__REQ__["endTime"]+ "','yyyymmdd')-to_date('"+__REQ__["startTime"]+ "','yyyymmdd')+1 runningDays1,BRANCHNUM from IB_LOG_LOGMASTER_LOG_BAK where branchnum in (select branchnum from ib_upm_branch_info START WITH branchnum in ("+ __REQ__["branchId"] +") CONNECT BY PRIOR branchnum =supebranchnum) group by DEVICENUM,BRANCHNUM) o on o.BRANCHNUM=a.BRANCHNUM
where a.TRANDATE between '"+__REQ__["startTime"]+ "' and '"+__REQ__["endTime"]+ "'
and a.branchnum in (select branchnum from ib_upm_branch_info START WITH branchnum in ("+ __REQ__["branchId"] +") CONNECT BY PRIOR branchnum =supebranchnum) and a.appnum='SS' and a.RETURNCODE='000000'
group by b.branchname,c.branchname,a.branchnum,h.transferNum,h.transferMoney,d.PASSWORDNUM,e.PERSONINFONUM,f.PRINTNUM,g.SIGNNUM,i.OPENCARDNUM,j.CARDRELOSSNUM,k.INTELLDEPOSITNUM,k.INTELLDEPOSITMONEY,l.FINANCNUM,l.FINANCMONEY,m.SUMDAYS,m.d
uj5u.com熱心網友回復:
好長的SQL,把執行計劃貼一下看看uj5u.com熱心網友回復:
沒有表別名根本沒法看,執行計劃也只能在你現有邏輯上進行修改,我只是覺得你整個處理邏輯都很笨重,很多查詢都可以放在一起寫。把邏輯精簡后寫出來,并給出建表陳述句與測驗資料
uj5u.com熱心網友回復:
不能拆開寫嗎?看著都頭暈uj5u.com熱心網友回復:
需要回傳的資料量大嗎,可能和網路有關。uj5u.com熱心網友回復:
看見遞回就猜到會慢了,陳述句太長沒法看轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/26360.html
標籤:開發
上一篇:求指導PLSQL截取欄位第二個或者第二個和第三個字符怎么寫?
下一篇:在創建企業級地理資料庫遇到的問題
