分析:
創(chuàng)新互聯(lián)是一家網(wǎng)站設(shè)計(jì)公司,集創(chuàng)意、互聯(lián)網(wǎng)應(yīng)用、軟件技術(shù)為一體的創(chuàng)意網(wǎng)站建設(shè)服務(wù)商,主營(yíng)產(chǎn)品:響應(yīng)式網(wǎng)站、高端網(wǎng)站設(shè)計(jì)、全網(wǎng)營(yíng)銷推廣。我們專注企業(yè)品牌在網(wǎng)站中的整體樹立,網(wǎng)絡(luò)互動(dòng)的體驗(yàn),以及在手機(jī)等移動(dòng)端的優(yōu)質(zhì)呈現(xiàn)。成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、移動(dòng)互聯(lián)產(chǎn)品、網(wǎng)絡(luò)運(yùn)營(yíng)、VI設(shè)計(jì)、云產(chǎn)品.運(yùn)維為核心業(yè)務(wù)。為用戶提供一站式解決方案,我們深知市場(chǎng)的競(jìng)爭(zhēng)激烈,認(rèn)真對(duì)待每位客戶,為客戶提供賞析悅目的作品,網(wǎng)站的價(jià)值服務(wù)。
由于優(yōu)化器無法判斷或獲得遠(yuǎn)端表的統(tǒng)計(jì)信息,故原執(zhí)行計(jì)劃默認(rèn)會(huì)采取把遠(yuǎn)程表(無論大?。├奖镜卦龠B接的方式執(zhí)行,
這樣如果遠(yuǎn)程表較大的情況將會(huì)比較緩慢,像上述查詢耗時(shí)在1分鐘以上。
原SQL語句:
Select Wb.*, (Select Wi.Nextarrivedate From Mbs7_Oms.Xs_Warearriveinfo@Dc.Moonbasadb.Com Wi Where Wi.Warecode = Wb.Warecode) As Nextarrivedate From Mbs7_Crm.Wi_Warebase@Dc.Moonbasadb.Com Wb ---這里遠(yuǎn)端表較大 Inner Join (Select Wa.Stylecode, Max(Wa.Warecode) As Warecode From Mbs7_Crm.Wi_Warebase@Dc.Moonbasadb.Com Wa Inner Join (Select Stylecode From Dc_Support.Kh_Visitpage Vis Where Vis.Cuscode = :B1 And Vis.Addtime >= Trunc(Sysdate - 31) And Vis.Addtime < Trunc(Sysdate - 30) And Rownum <= 5 Order By Addtime Desc) Vis On Wa.Stylecode = Vis.Stylecode Group By Wa.Stylecode) Wc On Wb.Warecode = Wc.Warecode
解決方案:
用以下HINTS方式加上去后,優(yōu)化器會(huì)調(diào)整執(zhí)行計(jì)劃,把運(yùn)算端控制在WB,并且遠(yuǎn)端表MBS7_CRM.WI_WAREBASE表字段的索引(STYLECODE)缺少連接索引,于是在目標(biāo)端創(chuàng)建以下索引進(jìn)行優(yōu)化,優(yōu)化后COST從7百多下降到20,運(yùn)行2秒內(nèi)可返回結(jié)果,性能增加不少。
遠(yuǎn)端表創(chuàng)建索引:
create index mbs7_crm.ix_WI_WAREBASE_STYLECODE on mbs7_crm.WI_WAREBASE(STYLECODE)
調(diào)優(yōu)后的SQL:
Select /*+DRIVING_SITE(WB)*/ Wb.*, (Select Wi.Nextarrivedate From Mbs7_Oms.Xs_Warearriveinfo@Dc.Moonbasadb.Com Wi Where Wi.Warecode = Wb.Warecode) As Nextarrivedate From Mbs7_Crm.Wi_Warebase@Dc.Moonbasadb.Com Wb ---遠(yuǎn)端表較大 Inner Join (Select Wa.Stylecode, Max(Wa.Warecode) As Warecode From Mbs7_Crm.Wi_Warebase@Dc.Moonbasadb.Com Wa Inner Join (Select Stylecode From Dc_Support.Kh_Visitpage Vis Where Vis.Cuscode = :B1 And Vis.Addtime >= Trunc(Sysdate - 31) And Vis.Addtime < Trunc(Sysdate - 30) And Rownum <= 5 Order By Addtime Desc) Vis On Wa.Stylecode = Vis.Stylecode Group By Wa.Stylecode) Wc On Wb.Warecode = Wc.Warecode
?版權(quán)聲明:本文為 天凱DBS 的原創(chuàng)文章,轉(zhuǎn)載請(qǐng)附上原文出處鏈接及本聲明,否則將追究法律責(zé)任。
原文鏈接: https://dbs-service.cn/a/173.html