国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專(zhuān)欄INFORMATION COLUMN

12C CBQT OR擴(kuò)展BUG帶來(lái)的問(wèn)題

IT那活兒 / 2176人閱讀
12C CBQT OR擴(kuò)展BUG帶來(lái)的問(wèn)題

點(diǎn)擊上方“IT那活兒”公眾號(hào),關(guān)注后了解更多內(nèi)容,不管IT什么活兒,干就完了!!!


案例一:12.2的OR查詢(xún)走不了索引

一條簡(jiǎn)單的SQL,在11G下運(yùn)行的很正常,走索引,到18C下,卻走了全表掃描,而且收集統(tǒng)計(jì)信息也無(wú)法走索引。
遇到這樣的情況,我的經(jīng)驗(yàn)就是懷疑這可能是一個(gè)BUG,具體解決可以從10053trace中分析或者搜索MOS文檔或者用神器SQLT的xplore功能。
廢話少說(shuō),先看SQL語(yǔ)句:
SELECT *
FROM (SELECT A.*,
ROW_NUMBER() OVER(PARTITION BY POLICYNO, CLASSCODE ORDER BY STOPDATE DESC) NN
FROM TESTID_RISKCON A
WHERE (POLICYNO = :B1 OR GPOLICYNO = :B1)
AND POLIST NOT IN (1)) T1
WHERE T1.NN = 1

Plan hash value: 1623810908
------------------------------------------------------------------------------------------------------------------

| Id  | Operation | Name           | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | Pstart| Pstop | A-Rows | A-Time   | Buffers |

------------------------------------------------------------------------------------------------------------------

| 0 | SELECT STATEMENT         | | 1 | | | 3672K(100)| | | | 0 |00:00:00.01 | 0 |

|* 1 | VIEW                    | | 1 | 256 | 99840 | 3672K (1)| 00:02:24 | | | 0 |00:00:00.01 | 0 |

|* 2 | WINDOW SORT PUSHED RANK| | 1 | 256 | 49664 | 3672K (1)| 00:02:24 | | | 0 |00:00:00.01 | 0 |

| 3 | PARTITION RANGE ALL | | 1 | 256 | 49664 | 3672K (1)| 00:02:24 | 1 | 43 | 0 |00:00:00.01 | 0 |

|* 4 | TABLE ACCESS FULL    | TESTID_RISKCON | 2 | 256 | 49664 | 3672K (1)| 00:02:24 | 1 | 43 | 0 |00:00:00.01 | 1 |

------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):

---------------------------------------------------

   1 - filter("T1"."NN"=1)

   2 - filter(ROW_NUMBER() OVER ( PARTITION BY "POLICYNO","CLASSCODE" ORDER BY INTERNAL_FUNCTION("STOPDATE") DESC )<=1)

   4 - filter((("GPOLICYNO"=:B1 OR "POLICYNO"=:B1) AND "POLIST"<>1))


TESTID_RISKCON表的列GPOLICYNO和PLICYNO都有索引,在12.2里走全表掃描,在11g里,對(duì)于這個(gè)OR條件,是可以走索引聯(lián)合查詢(xún)的,如下所示:


--------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)|
--------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | |      1 | |       | 12 (100)|
|* 1 |  VIEW | |      1 | 52 | 20280 | 12 (9)|
|* 2 |   WINDOW SORT PUSHED RANK | |      1 | 52 |  9828 | 12 (9)|
| 3 |    CONCATENATION | |      1 | |       | |
|* 4 |     TABLE ACCESS BY GLOBAL INDEX ROWID| TESTID_RISKCON |      1 | 2 |   378 | 3 (0)||* 5 |      INDEX RANGE SCAN | IDX_TESTID_RISKCON_01 |      1 | 2 |       | 2 (0)||* 6 |     TABLE ACCESS BY GLOBAL INDEX ROWID| TESTID_RISKCON |      1 | 50 |  9450 | 8 (0)||* 7 |      INDEX RANGE SCAN | IDX_TESTID_RISKCON_02 |      1 | 50 |       | 2 (0)|
--------------------------------------------------------------------------------------------------------------
                                                                                                             
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
   1 - SEL$2 / T1@SEL$1
   2 - SEL$2
   4 - SEL$2_1 / A@SEL$2
   5 - SEL$2_1 / A@SEL$2
   6 - SEL$2_2 / A@SEL$2_2
   7 - SEL$2_2 / A@SEL$2_2
對(duì)于這個(gè)問(wèn)題,首先是收集統(tǒng)計(jì)信息,然而并沒(méi)有啥用,因此,想到是BUG的原因,很簡(jiǎn)單,去MOS上搜索下,查到如下信息:
BadExecution Plan With OR Query After Update To 12.2.0.1 (Doc ID2536570.1)
按照給出的解決方案如下
Apply Patch 29450812 if available for your version
OR
Workarounds:
Set _optimizer_cbqt_or_expansion=false
Or 
Use USE_CONCAT hint in query
Or
Set optimizer_features_enable=12.1.0.2

主要原因是12.2開(kāi)始對(duì)or擴(kuò)展使用COSTBASEDTRANSFORMATION,導(dǎo)致BUG,最終通過(guò)在語(yǔ)句級(jí)關(guān)閉_optimizer_cbqt_or_expansion參數(shù)搞定。

案例二:12.2后到19c merge語(yǔ)句的OR操作走不了索引

ORACLE12.2開(kāi)始對(duì)OR擴(kuò)展使用CBQT,目的是用基于COST的方法,讓CBO更加準(zhǔn)確判斷可能的訪問(wèn)路徑,但是在12.2中卻存在BUG,導(dǎo)致不能走索引,從而影響性能,參考案例1,在12.2中也有個(gè)補(bǔ)丁可以解決:
CBQT ORE DOES NOT APPLY TO CORRELATED SCALAR SUBQUERY WITH OE
在18c中,可以通過(guò)fixcontrol參數(shù)控制這個(gè)補(bǔ)丁:
select value,sql_feature,description,optimizer_feature_enable from V$SYSTEM_FIX_CONTROL where BUGNO=26019148;

     VALUE SQL_FEATURE DESCRIPTION OPTIMIZER_FEATURE_ENABLE
---------- ------------------------------ ------------------------------ -------------------------
         1 QKSFM_OR_EXPAND_26019148 Allow ORE in select list subq 18.1.0
按理說(shuō)在18C已經(jīng)解決了這個(gè)問(wèn)題,但是在19C中測(cè)試,對(duì)于merge語(yǔ)句,還是無(wú)效(12.2后還是不行),如下所示:   
drop table t1; 
drop table t2;
create table t1 (id number, name varchar2(4000)) ;
create table t2 (id number, name varchar2(4000), ext varchar2(100)) ;
create index t2_idx1 on t2(id);
create index t2_idx2 on t2(name);

begin                                                                                  
  dbms_stats.gather_table_stats(ownname => user,tabname => t1,no_invalidate => false);
  dbms_stats.gather_table_stats(ownname => user,tabname => t2,no_invalidate => false);
end;
/
--MERGE語(yǔ)句如下
MERGE INTO t2 USING (
  SELECT id,name FROM t1
) x ON (
  x.id = t2.id or x.name = t2.name
)
WHEN MATCHED THEN UPDATE SET ext = xxx                                              
WHEN NOT MATCHED THEN INSERT (id) VALUES (1) ;    
執(zhí)行計(jì)劃如下所示:
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------
Plan hash value: 4096058702 
------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------
| 0 | MERGE STATEMENT | |     1 | 2067 |     4   (0)| 00:00:01 |
| 1 |  MERGE | T2 |       | |            | |
| 2 |   VIEW | |       | |            | |
| 3 |    MERGE JOIN OUTER | |     1 | 4094 |     4   (0)| 00:00:01 |
| 4 |     TABLE ACCESS FULL | T1 |     1 | 2015 |     2   (0)| 00:00:01 |
| 5 |     BUFFER SORT | |     1 | 2079 |     2   (0)| 00:00:01 |
| 6 |      VIEW | VW_LAT_8626BD41 |     1 | 2079 |     2   (0)| 00:00:01 |
|* 7 |       TABLE ACCESS FULL| T2 |     1 | 2079 |     2   (0)| 00:00:01 |
------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   7 - filter("ID"="T2"."ID" OR "NAME"="T2"."NAME")
在19c中對(duì)于merge語(yǔ)句竟然還走全表掃描,通過(guò)10053文件可以看到:
ORE: Checking validity of OR Expansion for query block SEL$2 (#0)
ORE: Predicate chain before QB validity check - SEL$2
"X"."ID"="T2"."ID" OR "X"."NAME"="T2"."NAME"
ORE: Predicate chain after QB validity check - SEL$2
"X"."ID"="T2"."ID" OR "X"."NAME"="T2"."NAME"
ORE: bypassed - Merge view query block.   
也就是說(shuō),在CBO檢查中,對(duì)于MERGE語(yǔ)句使用ORE(COSTOR EXPANSION)檢查沒(méi)有通過(guò),然后就走不能使用OR擴(kuò)展,從而走了全表掃描。
既然在對(duì)于MERGE語(yǔ)句的補(bǔ)丁26019148沒(méi)有解決,那么只能通過(guò)如下手段解決了:
修改參數(shù)_optimizer_cbqt_or_expansionfalse.
可以使用SQLPROFILE或SQLPATCH在語(yǔ)句級(jí)搞定,如下使用SQLPATCH:
DECLARE
  l VARCHAR2(32767);
BEGIN
  l := SYS.DBMS_SQLDIAG.create_sql_patch(
    sql_id => 67ujj1cy9c81f,
    hint_text => q[opt_param(_optimizer_cbqt_or_expansion,off)],
    name      => cbqt_ore_off);
END;
/
執(zhí)行計(jì)劃正確,使用了SQLPATCH,如下所示:
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------
Plan hash value: 2960188956
---------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------------------------
| 0 | MERGE STATEMENT | |     1 | 2067 |     2   (0)| 00:00:01 |
| 1 |  MERGE | T2 |       | |            | |
| 2 |   VIEW | |       | |            | |
| 3 |    MERGE JOIN OUTER | |     1 | 4094 |     2   (0)| 00:00:01 |
| 4 |     TABLE ACCESS FULL | T1 |     1 | 2015 |     2   (0)| 00:00:01 |
| 5 |     BUFFER SORT | |     2 | 4158 |     0   (0)| 00:00:01 |
| 6 |      VIEW | VW_LAT_8626BD41 |     2 | 4158 |     0   (0)| 00:00:01 |
| 7 |       CONCATENATION | |       | |            | |
| 8 |        TABLE ACCESS BY INDEX ROWID BATCHED| T2 |     1 | 2079 |     0   (0)| 00:00:01 |
|* 9 |         INDEX RANGE SCAN | T2_IDX2 |     1 | |     0   (0)| 00:00:01 |
|* 10 |        TABLE ACCESS BY INDEX ROWID BATCHED| T2 |     1 | 2079 |     0   (0)| 00:00:01 |
|* 11 |         INDEX RANGE SCAN | T2_IDX1 |     1 | |     0   (0)| 00:00:01 |
---------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   9 - access("NAME"="T2"."NAME")
  10 - filter(LNNVL("NAME"="T2"."NAME"))
  11 - access("ID"="T2"."ID")

Note
-----
   - SQL patch "cbqt_ore_off" used for this statement  
新特性固然好,但是往往會(huì)帶來(lái)一些新的BUG,需要通過(guò)分析確認(rèn),可以通過(guò)打補(bǔ)丁,改語(yǔ)句、SQLPROFILE、SQLPATCH等方式避免觸發(fā)BUG,從而獲得性能提升。

本文作者:丁 俊(上海新炬王翦團(tuán)隊(duì))

本文來(lái)源:“IT那活兒”公眾號(hào)

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/yun/129276.html

相關(guān)文章

  • 集成安裝之Oracle12C補(bǔ)丁升級(jí)數(shù)據(jù)字典更新報(bào)錯(cuò)處理

    集成安裝之Oracle12C補(bǔ)丁升級(jí)數(shù)據(jù)字典更新報(bào)錯(cuò)處理 img{ display:block; margin:0 auto !important; width:100%; } body{ width:75%; ...

    IT那活兒 評(píng)論0 收藏795
  • DBASK問(wèn)答集萃第四期

    摘要:?jiǎn)栴}九庫(kù)控制文件擴(kuò)展報(bào)錯(cuò)庫(kù)的擴(kuò)展報(bào)錯(cuò),用的是裸設(shè)備,和還是原來(lái)大小,主庫(kù)的沒(méi)有報(bào)錯(cuò),并且大小沒(méi)有變,求解釋。專(zhuān)家解答從報(bào)錯(cuò)可以看出,控制文件從個(gè)塊擴(kuò)展到個(gè)塊時(shí)報(bào)錯(cuò),而裸設(shè)備最大只支持個(gè)塊,無(wú)法擴(kuò)展,可以嘗試將參數(shù)改小,避免控制文件報(bào)錯(cuò)。 鏈接描述引言 近期我們?cè)贒BASK小程序新關(guān)聯(lián)了運(yùn)維之美、高端存儲(chǔ)知識(shí)、一森咖記、運(yùn)維咖啡吧等數(shù)據(jù)領(lǐng)域的公眾號(hào),歡迎大家閱讀分享。 問(wèn)答集萃 接下來(lái),...

    SKYZACK 評(píng)論0 收藏0
  • OGG Integrated Native DDL簡(jiǎn)單測(cè)試

    OGG Integrated Native DDL簡(jiǎn)單測(cè)試 img{ display:block; margin:0 auto !important; width:100%; } body{ width:75%;...

    IT那活兒 評(píng)論0 收藏1085

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<