大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
继续验证使用索引时,cbc latch相关情况,使用solaris中的dtrace
创新互联是一家专业提供泰山企业网站建设,专注与做网站、成都做网站、H5网站设计、小程序制作等业务。10年已为泰山众多企业、政府机构等服务。创新互联专业网站设计公司优惠进行中。编写dtrace脚本
more cbc.d #!/usr/sbin/dtrace -s -n char *memnr; int latchaddr; dtrace:::BEGIN { i=1; latchaddr=0; } pid$1::sskgslcas:entry { memnr=copyin(arg0,12); latchaddr=arg0; printf("[%2x%2x%2x%2x|%2x%2x%2x%2x|%2x%2x%2x%2x]",memnr[3],memnr[2],memnr[1],memnr[0],memnr[7],memnr[6],memnr[5],memnr[4],memnr [11],memnr[10],memnr[9],memnr[8]); printf("i=%d PID::entry:==%s:%s:%s:%s %x %x %x %x %x %x",i, probeprov, probemod, probefunc, probename,arg0,arg1,arg2,arg3,arg4,arg5); i=i+1; } pid$1::sskgslcas:return { memnr=copyin(latchaddr,12); printf("[%2x%2x%2x%2x|%2x%2x%2x%2x|%2x%2x%2x%2x]",memnr[3],memnr[2],memnr[1],memnr[0],memnr[7],memnr[6],memnr[5],memnr[4],memnr [11],memnr[10],memnr[9],memnr[8]); printf("i=%d PID::entry:==%s:%s:%s:%s %x %x %x",i, probeprov, probemod, probefunc, probename,latchaddr,arg0,arg1); i=i+1; }先测试非唯一索引:
session1:创建相应对象,并多次执行查询语句
create table a as select * from dba_objects; create index idx_a on a(object_id); select owner from a where object_id='30000'; SQL> select c.sid,spid,pid,a.SERIAL# from (select sid from v$mystat where rownum<=1) c,v$session a,v$process b where c.sid=a.sid and a.paddr=b.addr; SID SPID PID SERIAL# ---------- ------------ ---------- ---------- 159 1355 15 9session2:查询出block
set pagesize 50000 set linesize 10000 select file#,dbablk,tch,ba,HLADDR from x$bh a,dba_objects b where a.obj=b.data_object_id and object_name='IDX_A' order by FILE#,DBABLK; FILE# DBABLK TCH BA HLADDR ---------- ---------- ---------- -------- -------- 1 60641 0 5A4A8000 5F13949C 1 60642 0 5A350000 5F0FC938 1 60642 4 595EA000 5F0FC938 1 62091 0 58116000 5F14F564 1 62091 4 58468000 5F14F564 SQL> select segment_name,header_file,header_block from dba_segments where segment_name=upper('IDX_A'); SEGMENT_NAME HEADER_FILE HEADER_BLOCK --------------------------------------------------------------------------------- ----------- ------------ IDX_A 1 6064160641对段头块,60642为索引的root块,62091为leaf块
执行dtrace脚本,做跟踪,然后回到session1中再次执行查询语句
./cbc.d 1355 > logic_read.log
bash-3.2# cat logic_read.log|wc -l
25
session1:60642对应5F0FC938,在索引扫描时,对root块是共享cbc latch
SQL> oradebug call sskgslcas 0x5f0fc938 0 1 Function returned 1 SQL> select owner from a where object_id='30000'; OWNER ------------------------------ PUBLIC PUBLIC SQL> oradebug call sskgsldecr 0x5f0fc938 1 Function returned 162091为leaf块,在索引扫描时,对leaf块是一次共享cbc latch,三次独占cbc latch
bash-3.2# cat logic_read.log|grep -i 5F14F564 1 53243 sskgslcas:entry [ 0 0 0 0| 0 0 6 8| 0 0 07a]i=5 PID::entry:==pid1355:oracle:sskgslcas:entry 5f14f564 0 1 fdc4d278 fdc4d270 fdc4d134 1 53244 sskgslcas:return [ 0 0 0 1| 0 0 6 8| 0 0 07a]i=6 PID::entry:==pid1355:oracle:sskgslcas:return 5f14f564 16 1 1 53243 sskgslcas:entry [ 0 0 0 0| 0 0 6 9| 0 0 07a]i=11 PID::entry:==pid1355:oracle:sskgslcas:entry 5f14f564 0 2000000f ffffffff fdc4d278 fdc4d130 1 53244 sskgslcas:return [20 0 0 f| 0 0 6 9| 0 0 07a]i=12 PID::entry:==pid1355:oracle:sskgslcas:return 5f14f564 16 1 1 53243 sskgslcas:entry [ 0 0 0 0| 0 0 6 a| 0 0 07a]i=13 PID::entry:==pid1355:oracle:sskgslcas:entry 5f14f564 0 2000000f c4a89cc fdc4d134 fdc4d270 1 53244 sskgslcas:return [20 0 0 f| 0 0 6 a| 0 0 07a]i=14 PID::entry:==pid1355:oracle:sskgslcas:return 5f14f564 16 1 1 53243 sskgslcas:entry [ 0 0 0 0| 0 0 6 b| 0 0 07a]i=15 PID::entry:==pid1355:oracle:sskgslcas:entry 5f14f564 0 2000000f 0 fdc4d278 fdc4d26c 1 53244 sskgslcas:return [20 0 0 f| 0 0 6 b| 0 0 07a]i=16 PID::entry:==pid1355:oracle:sskgslcas:return 5f14f564 16 1上面是索引为非唯一索引时,cbc latch相关情况下面过程为测试
再测试唯一索引:
create table a as select * from dba_objects; create unique index idx_a on a(object_id); SQL> select c.sid,spid,pid,a.SERIAL# from (select sid from v$mystat where rownum<=1) c,v$session a,v$process b where c.sid=a.sid and a.paddr=b.addr; SID SPID PID SERIAL# ---------- ------------ ---------- ---------- 147 1374 16 12 select owner from a where object_id='30000'; SQL> select file#,dbablk,tch,ba,HLADDR from x$bh a,dba_objects b where a.obj=b.data_object_id and object_name='IDX_A' order by FILE#,DBABLK; FILE# DBABLK TCH BA HLADDR ---------- ---------- ---------- -------- -------- 1 60641 1 595EA000 5F13949C 1 60642 4 5A752000 5F0FC938 1 61343 3 584A0000 5F122270 SQL> / FILE# DBABLK TCH BA HLADDR ---------- ---------- ---------- -------- -------- 1 60641 1 595EA000 5F13949C 1 60642 6 5A752000 5F0FC938 1 61343 5 584A0000 5F122270 SQL> select segment_name,header_file,header_block from dba_segments where segment_name=upper('IDX_A'); SEGMENT_NAME -------------------------------------------------------------------------------- HEADER_FILE HEADER_BLOCK ----------- ------------ IDX_A 1 60641 60642为root块,61343为leaf块 bash-3.2# cat logic_read1.log CPU ID FUNCTION:NAME 0 53243 sskgslcas:entry [ 0 0 0 0| 0 0 074| 0 0 0 0]i=1 PID::entry:==pid1374:oracle:sskgslcas:entry 5ceb6fe8 0 930001 5d76abac 5ceb6fe8 5f8c4c6c 0 53244 sskgslcas:return [ 093 0 1| 0 0 074| 0 0 0 0]i=2 PID::entry:==pid1374:oracle:sskgslcas:return 5ceb6fe8 16 1 0 53243 sskgslcas:entry [ 0 0 0 0| 0 0 5db| 0 0 07a]i=3 PID::entry:==pid1374:oracle:sskgslcas:entry 5f0fc938 0 1 804510c 8045104 fdc18bf8 0 53244 sskgslcas:return [ 0 0 0 1| 0 0 5db| 0 0 07a]i=4 PID::entry:==pid1374:oracle:sskgslcas:return 5f0fc938 16 1 0 53243 sskgslcas:entry [ 0 0 0 0| 0 0 5 2| 0 0 07a]i=5 PID::entry:==pid1374:oracle:sskgslcas:entry 5f122270 0 1 804510c 8045104 fdc18bf8 0 53244 sskgslcas:return [ 0 0 0 1| 0 0 5 2| 0 0 07a]i=6 PID::entry:==pid1374:oracle:sskgslcas:return 5f122270 16 1 0 53243 sskgslcas:entry [ 0 0 0 0| 0 0 698| 0 0 07a]i=7 PID::entry:==pid1374:oracle:sskgslcas:entry 5f106340 0 1 fdc18f60 fdc18f58 fdc18f00 0 53244 sskgslcas:return [ 0 0 0 1| 0 0 698| 0 0 07a]i=8 PID::entry:==pid1374:oracle:sskgslcas:return 5f106340 16 1 0 53243 sskgslcas:entry [ 0 0 0 1| 0 0 075| 0 0 0 0]i=9 PID::entry:==pid1374:oracle:sskgslcas:entry 5ceb6fe8 1 930000 c4a88d0 5ceb6fe8 5f8c4c6c 0 53244 sskgslcas:return [ 093 0 0| 0 0 075| 0 0 0 0]i=10 PID::entry:==pid1374:oracle:sskgslcas:return 5ceb6fe8 16 1 bash-3.2# cat logic_read1.log|grep -i 5F0FC938 0 53243 sskgslcas:entry [ 0 0 0 0| 0 0 5db| 0 0 07a]i=3 PID::entry:==pid1374:oracle:sskgslcas:entry 5f0fc938 0 1 804510c 8045104 fdc18bf8 0 53244 sskgslcas:return [ 0 0 0 1| 0 0 5db| 0 0 07a]i=4 PID::entry:==pid1374:oracle:sskgslcas:return 5f0fc938 16 1 bash-3.2# cat logic_read1.log|grep -i 5F122270 0 53243 sskgslcas:entry [ 0 0 0 0| 0 0 5 2| 0 0 07a]i=5 PID::entry:==pid1374:oracle:sskgslcas:entry 5f122270 0 1 804510c 8045104 fdc18bf8 0 53244 sskgslcas:return [ 0 0 0 1| 0 0 5 2| 0 0 07a]i=6 PID::entry:==pid1374:oracle:sskgslcas:return 5f122270 16 1 bash-3.2# cat logic_read1.log|grep -i 5F106340 0 53243 sskgslcas:entry [ 0 0 0 0| 0 0 698| 0 0 07a]i=7 PID::entry:==pid1374:oracle:sskgslcas:entry 5f106340 0 1 fdc18f60 fdc18f58 fdc18f00 0 53244 sskgslcas:return [ 0 0 0 1| 0 0 698| 0 0 07a]i=8 PID::entry:==pid1374:oracle:sskgslcas:return 5f106340 16 1 唯一索引扫描时,对root块与leaf块都是一次共享cbc latch,对表块也是一次共享cbc latch逻辑读时的cbc latch(一):http://qhd2004.blog.51cto.com/629417/1576554
逻辑读时的cbc latch(二):http://qhd2004.blog.51cto.com/629417/1576579
参考:http://blog.itpub.net/321157/viewspace-730936/
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。