欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
關(guān)于shared cursor,parent cursor,child cursor

近日有朋友問(wèn)到 cursor 如何確定是否sharable的,Metalink Note 296377.1 說(shuō)得比較好,簡(jiǎn)單注釋如下:

1. shared SQL,parent cursor,child cursor 概念:

  所有SQL都是Oracle暗式共享的(implicitly sharable)。當用戶(hù)A發(fā)出一條SQL后,Oracle會(huì )根據SQL文本內容生成hash value(10g還有唯一的SQL_ID),以便能夠快速找到 Shared pool已經(jīng)存在的相同SQL。如果找不到,則Oracle會(huì )為這個(gè)SQL創(chuàng )建一個(gè)parent cursor和一個(gè)child cursor,這與SQL是否共享是沒(méi)有關(guān)系的。

  parent cursor包含了SQL TEXT和相關(guān)的hash value,v$sqlarea中的每一行代表了一個(gè)parent cursor,根據address表示了其內存地址。

 
child
cursor包含了SQL的metadata,即使得這個(gè)SQL可以執行的所有相關(guān)信息,如OBJECT和權限,優(yōu)化器設置,執行計劃等。v$sql中中
的每一行表示了一個(gè)child cursor,根據hash value和address與parent cursor 關(guān)聯(lián)。child
cursor有自己的address,即V$SQL.CHILD_ADDRESS。

  第一個(gè)child cursor總是使用0來(lái)表示其創(chuàng )建順序,V$SQL.CHILD_NUMBER = 0。因此,當從V$SQL_PLAN中查找某個(gè)SQL的執行計劃時(shí),要注意你寫(xiě)對了CHILD_NUMBER 。

如果有多個(gè)child cursor,則表示parent cursor有多個(gè)版本,v$sqlarea中的version_count字段就會(huì )紀錄下來(lái)。

2. 如何確定SQL 是否可以共享:

 
假設用戶(hù)A執行完一條SQL后,退出然后重新登陸,發(fā)出同一條SQL,則根據hash value找到Shared pool中已經(jīng)存在的parent
cursor,然后把 此parent cursor下的child cursor
list搜尋一邊,判斷metadata是否完全相同,如果是,則這條sql可以共享,就完成了一次soft parse。
 
  假設用戶(hù)B之后發(fā)出一條SQL文本完全一樣的SQL,但訪(fǎng)問(wèn)的table不是A用戶(hù)的,而是B用戶(hù)自己的,則metadata出現AUTH_CHECK_MISMATCH 和
  TRANSLATION_MISMATCH ,無(wú)法共享child cursor。Oracle會(huì )因此在此parent cursor 下創(chuàng )建一個(gè)新的child cursor,也就是一個(gè)hard parse。
 
  因此,SQL 是否可以共享是與parent cursor無(wú)關(guān)的,而是由child cursor決定的。
 
  從v$sql_shared_cursor可以獲得詳細的無(wú)法共享的原因:
  select * from v$sql_shared_cursor where kglhdpar = <parent address>  –or sql_id = ”
  select * from v$sql_shared_cursor where address = <parent address>   –or sql_id = ”

一般常見(jiàn)的mismatch是:
 
  OPTIMIZER_MISMATCH  : 優(yōu)化器環(huán)境設置不同,一般是optimizer相關(guān)參數
  BIND_MISMATCH      : 綁定變量的值的長(cháng)度在第二次執行的時(shí)候發(fā)生顯著(zhù)的變化    AUTH_CHECK_MISMATCH : 授權關(guān)系不匹配
  TRANSLATION_MISMATCH: 事務(wù)環(huán)境不匹配

其實(shí)最常見(jiàn)的是 BIND_MISMATCH ,在10g中可以測試一下:

create table t1(col1 varchar2(4000));

declare
v_col1 varchar2(4000);
begin
v_col1 := ‘t’;
for i in 1..30 loop
v_col1 := v_col1 ||’t';
insert into t1 values(v_col1);
end loop;
end;
/

–可以看出,變量長(cháng)度在30以下的時(shí)候,還是只有一個(gè)child cursor:

SQL_TEXT                    EXECUTIONS CHILD_NUMBER  ADDRESS  HASH_VALUE
————————— ———- ————  ——– ———-
INSERT INTO T1 VALUES(:B1 )         30            0  9E355F10 2351142747

declare
v_col1 varchar2(4000);
begin
v_col1 := ‘tttttttttttttttttttttttttttttt’;
for i in 31..4000 loop
v_col1 := v_col1 ||’t';
insert into t1 values(v_col1);
end loop;
end;
/

–可以看出,變量長(cháng)度變化導致了四個(gè)child cursor 存在:

SQL_TEXT                     EXECUTIONS CHILD_NUMBER CHILD_ADDRESS  ADDRESS  HASH_VALUE
—————————- ———- ———— ————-  ——– ———-
INSERT INTO T1 VALUES(:B1 )          32            0 9E355DCC       9E355F10 2351142747
INSERT INTO T1 VALUES(:B1 )          96            1 9E34BA18       9E355F10 2351142747
INSERT INTO T1 VALUES(:B1 )        1872            2 9E34B8D4       9E355F10 2351142747
INSERT INTO T1 VALUES(:B1 )        2060            3 9E34B790       9E355F10 2351142747

3. 使用cursor trace獲得child cursor 無(wú)法共享的詳細原因:

 –9i
  alter session set events ’10270 trace name context forever, level 10′;

  –10g
  alter system set events ‘immediate trace name cursortrace level 577, address <hash_value>’;
   –(level 578/580 can be used for high level tracing (577=level 1, 578=level 2, 580=level 3)

  alter system set events ‘immediate trace name cursortrace level 2147483648, address 1′;

4. cursor_sharing=similar 和 force 時(shí)的行為

   cursor_sharing=similar 時(shí)
   
  如果 predicate 為范圍( >,<,>=,<= ),則出現literal replacement 時(shí),一般不會(huì )share cursor,除非literal 完全相等;
  因為在CBO下,這個(gè)時(shí)候的literal被用來(lái)確定執行計劃,literal replacement會(huì )被認 為是UNSAFE的,無(wú)法共享。
  在RBO時(shí)候,CURSOR是會(huì )共享的。
          
  CBO下,如果 predicate 為=,則出現literal replacement 時(shí),是否share cursor,取決于這個(gè)column是否有histgrams。
    
   cursor_sharing=force 時(shí),不管 predicate,如果出現literal replacement ,則會(huì )shared cursor,但往往容易得到性能較差的執行計劃。

可以使用10046 判斷一個(gè)bind variable 是否 unsafe:

The flag oacfl2 in 9i and fl2 in 10g will show if a variable is unsafe.

  BINDS #2:
 
bind 0: dty=2 mxl=22(04) mal=00 scl=00 pre=00 acflg=10 oacfl2=500
size=24 ffset=0 bfp=1036d6408 bln=22 avl=04 flg=09 value=16064
  bind 1: dty=2 mxl=22(04) mal=00 scl=00 pre=00 acflg=10 oacfl2=500 size=24 ffset=0 bfp=1036d4340 bln=22 avl=04 flg=09
 
  If you note oacfl2=500
  #define UACFBLTR 0×00000100 /* Bind was generated by LiTeRal replacement */
  #define UACFUNSL 0×00000200 /* UNSafe Literal */
  #define UACFNDTL 0×00000400 /* Non-DaTa LiteRal */

在11g中,child cursor 共享這部分改動(dòng)不小,如果從10g升級上去,AWR往往發(fā)現某些SQL的VERSION COUNT會(huì )變多,可能會(huì )命中BUG。

One Response to [zt]關(guān)于 shared cursor,parent cursor,child cursor

  1. powpeo says:

    11g中,視圖v$sql 增加了is_bind_sensitive is_bind_aware is_shareable列:is_bind_sensitive: indicates not only whether bind variable peeking was used to generatethe execution plan but also whether the execution plan depends on the peeked value. Ifthis is the case, the column is set to Y; otherwise, it’s set to N.is_bind_aware: indicates whether the cursor is using extended cursor sharing. If yes, thecolumn is set to Y; if not, it’s set to N. If set to N, the cursor is obsolete, and it will no longerbe used.is_shareable: indicates whether the cursor can be shared. If it can, the column is set to Y;otherwise, it’s set to N. If set to N, the cursor is obsolete, and it will no longer be used.

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
由 bind_mismatch 引起的 大量 version_count 問(wèn)題
ORACLE ORA-03137錯誤處理
mysql遞歸查詢(xún)的笨拙實(shí)現 - 不拋棄,不放棄 - ITPUB個(gè)人空間 - powered by X-Space
入門(mén)基礎:Oracle中SQL語(yǔ)句解析的步驟
python實(shí)現ssh通過(guò)跳板機連接mysql
ORA --600--qerrmObnd1
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久