oracle之sequence的cache解析,一篇不錯的文章
阿新 • • 發佈:2019-02-17
SQL> oradebug setmypid; 已處理的語句 SQL> oradebug unlimit; 已處理的語句 SQL> oradebugevent 10046 trace name context forever, level 12 已處理的語句 SQL> select scott.seq_nocache.nextval from dual; NEXTVAL ---------- 9 SQL> select scott.seq_nocache.nextval fromdual; NEXTVAL ---------- 10 SQL> select scott.seq_nocache.nextval from dual; NEXTVAL ---------- 11 SQL> select scott.seq_cache.nextval from dual; NEXTVAL ---------- 9 SQL> select scott.seq_cache.nextval from dual; NEXTVAL---------- 10 SQL> select scott.seq_cache.nextval from dual; NEXTVAL ---------- 11 SQL> oradebug event 10046 trace name context off; 已處理的語句 SQL> oradebug tracefile_name c:\tool\oracle\oracle\product\10.2.0\admin\ots\udump\ots_ora_5932.trc 開啟跟蹤檔案,我們首先分析nocache的幾次呼叫片段。--篇幅原因,本部分有省略; ===================== PARSING IN CURSOR #1 len=42 dep=0 uid=0 ct=3 lid=0 tim=16143418536 hv=311402377 ad='248b5c60' select scott.seq_nocache.nextval from dual–第一次呼叫nocache END OF STMT PARSE #1:c=0,e=110,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=16143418526 BINDS #1: EXEC #1:c=0,e=13893,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=16143450260 WAIT #1: nam='SQL*Net message to client' ela= 8 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=16143453714 ===================== PARSING IN CURSOR #2 len=129 dep=1 uid=0 ct=6 lid=0 tim=16143457545 hv=2635489469 ad='2891ff84' update seq$ set increment$=:2,minvalue=:3,maxvalue=:4,cycle#=:5,order$=:6,cache=:7,highwater=:8,audit$=:9,flags=:10 where obj#=:1–第一次迴圈遞迴; END OF STMT PARSE #2:c=0,e=129,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=4,tim=16143457535 BINDS #2: kkscoacd Bind#0 oacdty=02 mxl=22(02) mxlc=00 mal=00 scl=00 pre=00 oacflg=18 fl2=0001 frm=00 csi=00 siz=24 ff=0 kxsbbbfp=248c69dc bln=24 avl=02 flg=09 value=1 Bind#1 oacdty=02 mxl=22(02) mxlc=00 mal=00 scl=00 pre=00 oacflg=18 fl2=0001 frm=00 csi=00 siz=24 ff=0 kxsbbbfp=248c69ee bln=24 avl=02 flg=09 value=1 Bind#2 oacdty=02 mxl=22(15) mxlc=00 mal=00 scl=00 pre=00 oacflg=18 fl2=0001 frm=00 csi=00 siz=24 ff=0 kxsbbbfp=248c6a00 bln=24 avl=15 flg=09 value=999999999999999999999999999 Bind#3 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=08 fl2=0001 frm=00 csi=00 siz=24 ff=0 kxsbbbfp=088cefb8 bln=24 avl=01 flg=05 value=0 Bind#4 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=08 fl2=0001 frm=00 csi=00 siz=24 ff=0 kxsbbbfp=088cef94 bln=24 avl=01 flg=05 value=0 Bind#5 oacdty=02 mxl=22(01) mxlc=00 mal=00 scl=00 pre=00 oacflg=18 fl2=0001 frm=00 csi=00 siz=24 ff=0 kxsbbbfp=248c6a12 bln=24 avl=01 flg=09 value=0 Bind#6 oacdty=02 mxl=22(02) mxlc=00 mal=00 scl=00 pre=00 oacflg=18 fl2=0001 frm=00 csi=00 siz=24 ff=0 kxsbbbfp=248c6a24 bln=24 avl=02 flg=09 value=10 Bind#7 oacdty=01 mxl=32(32) mxlc=00 mal=00 scl=00 pre=00 oacflg=18 fl2=0001 frm=01 csi=852 siz=32 ff=0 kxsbbbfp=248c6a36 bln=32 avl=32 flg=09 value="--------------------------------" Bind#8 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=08 fl2=0001 frm=00 csi=00 siz=24 ff=0 kxsbbbfp=088cef70 bln=24 avl=02 flg=05 value=8 Bind#9 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=08 fl2=0001 frm=00 csi=00 siz=24 ff=0 kxsbbbfp=088cefdc bln=22 avl=04 flg=05 value=113487 (有省略……) ===================== PARSING IN CURSOR #2 len=42 dep=0 uid=0 ct=3 lid=0 tim=16145504123 hv=311402377 ad='248b5c60' select scott.seq_nocache.nextval from dual–第二次呼叫 END OF STMT PARSE #2:c=0,e=50,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=16145504114 BINDS #2: EXEC #2:c=15625,e=4237,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=16145528418 WAIT #2: nam='SQL*Net message to client' ela= 8 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=16145532367 ===================== PARSING IN CURSOR #1 len=129 dep=1 uid=0 ct=6 lid=0 tim=16145536517 hv=2635489469 ad='2891ff84' update seq$ set increment$=:2,minvalue=:3,maxvalue=:4,cycle#=:5,order$=:6,cache=:7,highwater=:8,audit$=:9,flags=:10 where obj#=:1 END OF STMT PARSE #1:c=0,e=49,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=4,tim=16145536507 BINDS #1: kkscoacd (……) Bind#6 oacdty=02 mxl=22(02) mxlc=00 mal=00 scl=00 pre=00 oacflg=18 fl2=0001 frm=00 csi=00 siz=24 ff=0 kxsbbbfp=248c6a24 bln=24 avl=02 flg=09 value=11 Bind#7 oacdty=01 mxl=32(32) mxlc=00 mal=00 scl=00 pre=00 oacflg=18 fl2=0001 frm=01 csi=852 siz=32 ff=0 kxsbbbfp=248c6a36 bln=32 avl=32 flg=09 value="--------------------------------" Bind#8 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=08 fl2=0001 frm=00 csi=00 siz=24 ff=0 kxsbbbfp=088cef70 bln=24 avl=02 flg=05 value=8 Bind#9 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=08 fl2=0001 frm=00 csi=00 siz=24 ff=0 kxsbbbfp=088cefdc bln=22 avl=04 flg=05 value=113487 ===================== PARSING IN CURSOR #1 len=42 dep=0 uid=0 ct=3 lid=0 tim=16147403782 hv=311402377 ad='248b5c60' select scott.seq_nocache.nextval from dual–第三次呼叫 END OF STMT ===================== PARSING IN CURSOR #2 len=129 dep=1 uid=0 ct=6 lid=0 tim=16147424639 hv=2635489469 ad='2891ff84' update seq$ set increment$=:2,minvalue=:3,maxvalue=:4,cycle#=:5,order$=:6,cache=:7,highwater=:8,audit$=:9,flags=:10 where obj#=:1 END OF STMT PARSE #2:c=0,e=43,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=4,tim=16147424633 BINDS #2: kkscoacd Bind#6 oacdty=02 mxl=22(02) mxlc=00 mal=00 scl=00 pre=00 oacflg=18 fl2=0001 frm=00 csi=00 siz=24 ff=0 kxsbbbfp=248c6a24 bln=24 avl=02 flg=09 value=12 Bind#7 oacdty=01 mxl=32(32) mxlc=00 mal=00 scl=00 pre=00 oacflg=18 fl2=0001 frm=01 csi=852 siz=32 ff=0 kxsbbbfp=248c6a36 bln=32 avl=32 flg=09 value="--------------------------------" Bind#8 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=08 fl2=0001 frm=00 csi=00 siz=24 ff=0 kxsbbbfp=088cef70 bln=24 avl=02 flg=05 value=8 Bind#9 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=08 fl2=0001 frm=00 csi=00 siz=24 ff=0 kxsbbbfp=088cefdc bln=22 avl=04 flg=05 value=113487