由于LMT下不再具有freelist参数,但理解了freelist的作用后都知道,这是难以通过其他途径来解决的,freelist本身的作用不可抹杀,具有很多的好处,据说oracle其中一个副总裁当初是一个程序员,就是因为在 空间管理和分配算法中的出色表现而平步青云的,
其中最重要的一环就是 freelist 的设计
废话不说了
根据两个表(LMT0,LMT1)的实验可以看出:
SQL> begin
2 for i in 1..10000 loop
3 insert into lmt0 values(i);
4 end loop;
5 end;
6 /
我们这时来看 segment header :
*** 2003-02-18 10:07:19.984
Start dump data blocks tsn: 7 file#: 8 minblk 9 maxblk 9
buffer tsn: 7 rdba: 0x02000009 (8/9)
scn: 0x0000.0008dc4a seq: 0x03 flg: 0x00 tail: 0xdc4a1003
frmt: 0x02 chkval: 0x0000 type: 0x10=DATA SEGMENT HEADER - UNLIMITED
Extent Control Header
-----------------------------------------------------------------
Extent Header:: spare1: 0 space2: 0 #extents: 4 #blocks: 63
last map 0x00000000 #maps: 0 offset: 4128
Highwater:: 0x02000023 ext#: 1 blk#: 10 ext size: 16
#blocks in seg. hdr's freelists: 10
#blocks below: 25
mapblk 0x00000000 offset: 1
Unlocked
Map Header:: next 0x00000000 #extents: 4 obj#: 25098 flag: 0x40000000
Extent Map
-----------------------------------------------------------------
0x0200000a length: 15
0x02000019 length: 16
0x02000029 length: 16
0x020000d9 length: 16
nfl = 1, nfb = 1 typ = 1 nxf = 0
SEG LST:: flg: USED lhd: 0x02000019 ltl: 0x02000022
End dump data blocks tsn: 7 file#: 8 minblk 9 maxblk 9
我们发现:
#blocks in seg. hdr's freelists: 10 freeslit从0变成了10,
但暂时只有一个freelist被使用: SEG LST:: flg: USED lhd: 0x02000019 ltl: 0x02000022
再看另一个表:
SQL> insert into lmt1 select rownum from all_objects;
已创建24746行。
SQL> commit;
Start dump data blocks tsn: 7 file#: 8 minblk 57 maxblk 57
buffer tsn: 7 rdba: 0x02000039 (8/57)
scn: 0x0000.0008dc60 seq: 0x02 flg: 0x00 tail: 0xdc601002
frmt: 0x02 chkval: 0x0000 type: 0x10=DATA SEGMENT HEADER - UNLIMITED
Extent Control Header
-----------------------------------------------------------------
Extent Header:: spare1: 0 space2: 0 #extents: 10 #blocks: 159
last map 0x00000000 #maps: 0 offset: 4128
Highwater:: 0x02000063 ext#: 2 blk#: 10 ext size: 16
#blocks in seg. hdr's freelists: 4
#blocks below: 41
mapblk 0x00000000 offset: 2
Unlocked
Map Header:: next 0x00000000 #extents: 10 obj#: 25099 flag: 0x40000000
Extent Map
-----------------------------------------------------------------
0x0200003a length: 15
0x02000049 length: 16
0x02000059 length: 16
0x02000069 length: 16
0x02000079 length: 16
0x02000089 length: 16
0x02000099 length: 16
0x020000a9 length: 16
0x020000b9 length: 16
0x020000c9 length: 16
nfl = 1, nfb = 1 typ = 1 nxf = 0
SEG LST:: flg: USED lhd: 0x0200005f ltl: 0x02000062
End dump data blocks tsn: 7 file#: 8 minblk 57 maxblk 57
我们发现这样插入的时候,
#blocks in seg. hdr's freelists: 4
SEG LST:: flg: USED lhd: 0x0200005f ltl: 0x02000062
再继续插入:
SQL> begin for i in 1..10000 loop
2 insert into lmt1 values(i);
3 end loop;
4 end;
5 /
PL/SQL 过程已成功完成。
这个时候再看segment header:
Start dump data blocks tsn: 7 file#: 8 minblk 57 maxblk 57
buffer tsn: 7 rdba: 0x02000039 (8/57)
scn: 0x0000.0008dcbc seq: 0x01 flg: 0x00 tail: 0xdcbc1001
frmt: 0x02 chkval: 0x0000 type: 0x10=DATA SEGMENT HEADER - UNLIMITED
Extent Control Header
-----------------------------------------------------------------
Extent Header:: spare1: 0 space2: 0 #extents: 10 #blocks: 159
last map 0x00000000 #maps: 0 offset: 4128
Highwater:: 0x02000073 ext#: 3 blk#: 10 ext size: 16
#blocks in seg. hdr's freelists: 5
#blocks below: 57
mapblk 0x00000000 offset: 3
Unlocked
Map Header:: next 0x00000000 #extents: 10 obj#: 25099 flag: 0x40000000
Extent Map
-----------------------------------------------------------------
0x0200003a length: 15
0x02000049 length: 16
0x02000059 length: 16
0x02000069 length: 16
0x02000079 length: 16
0x02000089 length: 16
0x02000099 length: 16
0x020000a9 length: 16
0x020000b9 length: 16
0x020000c9 length: 16
nfl = 1, nfb = 1 typ = 1 nxf = 0
SEG LST:: flg: USED lhd: 0x0200006e ltl: 0x02000072
End dump data blocks tsn: 7 file#: 8 minblk 57 maxblk 57
*** 2003-02-18 10:21:23.171
我们发现:
#blocks in seg. hdr's freelists: 5
SEG LST:: flg: USED lhd: 0x0200006e ltl: 0x02000072
这个时候找到 lhd: 0x0200006e 这个块来看:
Start dump data blocks tsn: 7 file#: 8 minblk 110 maxblk 110
buffer tsn: 7 rdba: 0x0200006e (8/110)
scn: 0x0000.0008dcbe seq: 0x10 flg: 0x00 tail: 0xdcbe0610
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump: 0x0200006e
Object id on Block? Y
seg/obj: 0x620b csc: 0x00.8dc9e itc: 1 flg: O typ: 1 - DATA
fsl: 0 fnx: 0x200006f ver: 0x01
Itl Xid Uba Flag Lck Scn/Fsc
0x01 xid: 0x0006.049.000000c1 uba: 0x008005ae.00c4.10 ---- 322 fsc 0x0000.00000000
data_block_dump
===============
tsiz: 0x1fb8
hsiz: 0x296
pbl: 0x08196c44
bdba: 0x0200006e
flag=-----------
ntab=1
nrow=322
frre=-1
fsbo=0x296
fseo=0x16ee
avsp=0x11d0
tosp=0x11d0
0xeti[0] nrow=322 offs=0
0x12ri[0] offs=0x1fb1
0x14ri[1] offs=0x1faa
0x16ri[2] offs=0x1fa3
该块中:有 0xeti[0] nrow=322 offs=0 可看出已经插入 322 条数据
因为该块是 : 0x200006e, 所以该块freelist指向的next 是下面所指
fsl: 0 fnx: 0x200006f ver: 0x01
由此可以看出,LMT在本质上,和 DMT的freelist是一样的原理
只不过在扩展和管理的算法上有了重大差异
但到底这个算法是怎样的,暂时不得而知了
FW:
关于LMT的存储结构问题
顺便简单交代一下:
如上:
Map Header:: next 0x00000000 #extents: 4 obj#: 25098 flag: 0x40000000
Extent Map
-----------------------------------------------------------------
0x0200000a length: 15
0x02000019 length: 16
0x02000029 length: 16
0x020000d9 length: 16
由于 空间的扩展,可能会有多个块被用来记录 bitmap ,在本例子中只有一个块记录,所以
Map Header:: next 0x00000000 #extents: 4 obj#: 25098
next 是没有值的, 该表只有4 extents ,obj编号 25098
0x0200000a length: 15 表示,该 extent 从 0x0200000a 这个块开始,一共15块
之所以这里是15而后面都是16是因为有一个block被多做了 segment geader
我们可以看出
0x0200000a + 15 正好是 0x02000019 ,这表示这两个extent是连续的