在"logical rowid的结构"这篇文章里,我人为构造了一个stale的physical guess的例子,这里我们继续,做如下的三个测试:
1、修改logical rowid的primary key但不修改physical guess,以验证oracle在physical guess准确的情况下是否需要primary key。
2、同时修改logical rowid的primary key和physical guess,以验证oracle在这样的情况下的表现。
3、修改IOT里一条记录的primary key,验证在这种情况下其索引上的physical guess是否会stale。
这里的测试对象是ID为2的那条记录:
SQL> select id,rowid,dump(rowid,16) from t3;
ID ROWID DUMP(ROWID,16)
---------- ------------------------------- --------------------------------------------------------------------------------
1 *BCFAABMCwQL+ Typ=208 Len=10: 2,4,21,40,0,13,2,c1,2,fe
2 *BCFAABMCwQP+ Typ=208 Len=10: 2,4,21,40,0,13,2,c1,3,fe
3 *BCFAABMCwQT+ Typ=208 Len=10: 2,4,21,40,0,13,2,c1,4,fe
4 *BCFAABQCwQX+ Typ=208 Len=10: 2,4,21,40,0,14,2,c1,5,fe
这是未修改前的查询结果:
SQL> select id,substr(c2,1,1) from t3 where c1='B';
ID SUBSTR(C2,1,1)
---------- --------------
2 B
具体的测试过程我就不再赘述了,我们来看一下上述三个测试的结果。
测试一:
这里我是把主键ID=2改为3,即C1 04,但不改physical guess 0x21400013
BBED> modify /x 0x
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /dras20/astca/test01.dbf (133)
Block: 42 Offsets: 8094 to 8191 Dba:0x
------------------------------------------------------------------------
04000142
ac000300 01000100 40dd6700 000040dd
0601
<32 bytes per line>
改完后startup上述数据库再执行上述查询:
SQL> select id,substr(c2,1,1) from t3 where c1='B';
ID SUBSTR(C2,1,1)
---------- --------------
SQL> select /*+ full(t3) */id,substr(c2,1,1) from t3 where c1='B';
ID SUBSTR(C2,1,1)
---------- --------------
2 B
从测试结果里可以看到,只要我改了主键,即使physical guess是准确的,oracle这里也会得到错误的值。
既然测试一的结果是这样,那测试二也就不用做了。
测试三:
ID=1的那条记录的physical guess是0x21400013,我现在把ID=1改成ID=5,这时候ID=1的那条记录必然要挪到0x21400014中,等修改完成后我们再dump一下,看看ID=5的那条记录所对应的index block的physical guess是0x21400013还是0x21400014。
SQL> update t3 set id=5 where id=1;
1 row updated
SQL> commit;
Commit complete
SQL> select id,rowid,dump(rowid,16) from t3;
ID ROWID DUMP(ROWID,16)
---------- ------------------------------- --------------------------------------------------------------------------------
2 *BCFAABMCwQP+ Typ=208 Len=10: 2,4,21,40,0,13,2,c1,3,fe
3 *BCFAABMCwQT+ Typ=208 Len=10: 2,4,21,40,0,13,2,c1,4,fe
4 *BCFAABQCwQX+ Typ=208 Len=10: 2,4,21,40,0,14,2,c1,5,fe
5 *BCFAABQCwQb+ Typ=208 Len=10: 2,4,21,40,0,14,2,c1,6,fe
SQL> alter system checkpoint;
System altered
Dump一下133_42这个index block:
row#0[8017] flag: K--D-, lock: 2
col 0; len 1; (1): 41
col 1; len 2; (2): c1 02
tl: 8 fb: --H-FL-- lb: 0x0 cc: 1
col 0: [ 4]
Dump of memory from 0x0000000110275FB8 to 0x0000000110275FBC
110275FB0 21400013 [!@..]
row#1[7957] flag: K----, lock: 2
col 0; len 1; (1): 41
col 1; len 2; (2): c1 06
tl: 8 fb: --H-FL-- lb: 0x0 cc: 1
col 0: [ 4]
Dump of memory from 0x
row#2[8002] flag: K----, lock: 0
col 0; len 1; (1): 42
col 1; len 2; (2): c1 04
tl: 8 fb: --H-FL-- lb: 0x0 cc: 1
col 0: [ 4]
Dump of memory from 0x0000000110275FA9 to 0x0000000110275FAD
110275FA0 04214000 13050201 [.!@.....]
row#3[7987] flag: K----, lock: 0
col 0; len 1; (1): 43
col 1; len 2; (2): c1 04
tl: 8 fb: --H-FL-- lb: 0x0 cc: 1
col 0: [ 4]
Dump of memory from 0x
row#4[7972] flag: K----, lock: 0
col 0; len 1; (1): 44
col 1; len 2; (2): c1 05
tl: 8 fb: --H-FL-- lb: 0x0 cc: 1
col 0: [ 4]
Dump of memory from 0x
----- end of leaf block dump -----
End dump data blocks tsn: 84 file#: 133 minblk 42 maxblk 42
现在ID=5所在的offset是7957+68+24=8049
好了,我们现在来看其physical guess:
BBED> set offset 8049
OFFSET 8049
BBED> dump
File: /dras20/astca/test01.dbf (133)
Block: 42 Offsets: 8049 to 8191 Dba:0x
------------------------------------------------------------------------
04020141
<32 bytes per line>
Leave a comment