原文转自:http://www.ixdba.net/article/e4/1605.html 如有侵权,请联系我,我会立即删除。
因为ASSM的官方文档很少,经过多次的查证之后,终于弄明白了ASSM管理(BMB段管理)的内部机理,现在发表给大家共享.
因为资料有限,如果有错误,请大家指正为了进一步让大家明白ASSM,先说明ASSM的基本情况!
-----------------------------------------------------------------------------------------------------
在920以前,表的剩余空间的管理与分配都是由链接列表freelist来完成的,因为freelist存在串行的问题因此容易引起往往容易引起段头的争用与空间的浪费(其实这一点并不明显),最主要的还是因为需要DBA 花费大量的精力去管理这些争用并监控表的空间利用。
自动段空间管理(ASSM),它首次出现在Oracle920里。有了ASSM,链接列表freelist被位图所取代,它是一个二进制的数组,能够迅速有效地管理存储扩展和剩余区块(free block),因此能够改善分段存储本质,ASSM表空间上创建的段还有另外一个称呼叫Bitmap Managed Segments(BMB 段)。
让我们看看位图freelist是如何实现的。我会从使用区段空间管理自动参数创建tablespace开始:
create tablespace demo
datafile '/ora01/oem/demo01.dbf '
size 5m
EXTENT MANAGEMENT LOCAL -- Turn on LMT (本地管理表空间)
SEGMENT SPACE MANAGEMENT AUTO -- Turn on ASSM;
一旦你定义好了tablespace,那么表和索引就能够使用各种方法很容易地被移动到新的tablespace里,带有ASSM的本地管理tablespace会略掉任何为PCTUSED、NEXT和FREELISTS所指定的值。
当表格或者索引被分配到这个tablespace以后,用于独立对象的PCTUSED的值会被忽略(在自动段空间管理中,没有prtused参数),而Oracle9i会使用位图数组来自动地管理tablespace里表格和索引的freelist。对于在LMT(本地管理表空间)的tablespace内部创建的表格和索引而言,这个NEXT扩展子句是过时的,因为由本地管理的tablespace会管理它们。但是,INITIAL参数仍然是需要的,因为Oracle不可能提前知道初始表格加载的大小。对于ASSM而言,INITIAL最小的值是三个块。
新的管理机制用位图来跟踪或管理每个分配到对象的块,每个块有多少剩余空间根据位图的状态来确定,如>75%,50%-75%,25%-50%和<25%,也就是说位图其实采用了四个状态位来代替以前的pctused(注意是数据块的一个参数,不是段的),什么时候该利用该数据块则由设定的pctfree来确定。
在没有多个freelist的时候,每个Oracle表格和索引在表格的头部都曾有一个数据块,用来管理对象所使用的剩余区块,并为任何SQL插入声明所创建的新数据行提供数据块。当数据缓冲内的数据块由于被另一个DML事务处理锁定而无法使用的时候,缓冲区忙等待就会发生。当你需要将多个任务插入到同一个表格里的时候,这些任务就被强制等待,而同时Oracle会在同时分派剩余的区块,一次一个。
有了ASSM之后,Oracle宣称显著地提高了DML并发操作的性能,因为(同一个)位图的不同部分可以被同时使用,这样就消除了寻找剩余空间的串行化。根据Oracle的测试结果,使用位图freelist会消除所有分段头部(对资源)的争夺,还能获得超快的并发插入操作
· 一旦DBA被分配之后,它就无法控制tablespace内部的独立表格和索引的存储行为。
· 大型对象不能够使用ASSM,而且必须为包含有LOB数据类型的表格创建分离的tablespace。
· 你不能够使用ASSM创建临时的tablespace。这是由排序时临时分段的短暂特性所决定的。
· 只有本地管理的tablespace才能够使用位图分段管理。
· 使用超高容量的DML(例如INSERT、UPDATE和DELETE等)的时候可能会出现性能上的问题。
ASSM到底是怎么回事,表是怎么结构的呢?
----------------------------------------------------------------------------------
关键字:ASSM,自动段管理
BMB Segment 位图块段管理
1、我们先创建一个本地管理的表空间,采用段自动管理方式
SQL>
create tablespace demo
datafile '/ora01/oem/demo01.dbf '
size 50m
EXTENT MANAGEMENT LOCAL --一定是本地管理
SEGMENT SPACE MANAGEMENT AUTO; --ASSM管理的标志
2、创建同样一个表
[color=navy]SQL>
create table demotab ( x number ) tablespace demo
storage (initial 1000K);
Table created
我们指定初试区间大小是1000K
SQL>
select t.table_name,t.initial_extent,t.next_extent,t.pct_free,t.pct_used fromuser_tables t where t.table_name = 'DEMOTAB';
TABLE_NAME INITIAL_EXTENT NEXT_EXTENT PCT_FREE PCT_USED
----------------- ------------- -------------- ----------- ----------
DEMOTAB 1024000 10
可以看到,NEXT_EXTENT与PCT_USED都为空。
3、执行该过程,检查表的初始状态
SQL> exec show_space('demotab');
Total Blocks............................128
Total Bytes.............................1048576
Unused Blocks...........................125
Unused Bytes............................1024000
Last Used Ext FileId....................7
Last Used Ext BlockId...................8
Last Used Block.........................3
从这里我们能看到一些该表的特性,其中最引人注意的就是表头了,占用了三个块的大小(128-125)
另外一个注意的地方就是该表从第8个块开始,但是实际上这里是错误的,应当是从第9个块开始,文件头占用了64K的空间等于8个块。
我们从dba_extent中也能看到这样的信息,实际上是从第9个块开始的。
SQL> select t.segment_name,t.extent_id,t.block_id fromdba_extents twhere t.segment_name = 'DEMOTAB';
SEGMENT_NAME EXTENT_ID BLOCK_ID
-------------------------- ---------- ----------
DEMOTAB 0 9
DEMOTAB 1 17
……
从这里可以看到,第一个区间的开始块是9
4、我直接开始分析第9,10,11个块(段头)
SQL> alter system dump datafile 7 block 9;
System altered
SQL> alter system dump datafile 7 block 10;
System altered
SQL> alter system dump datafile 7 block 11;
System altered
Start dump data blocks tsn: 6 file#: 7 minblk 9 maxblk 9
buffer tsn: 6 rdba: 0x06800009 (7/9)
scn: 0x0000.00181a2c seq: 0x01 flg: 0x04 tail: 0x1a2c2001
frmt: 0x02 chkval: 0x30a6 type: 0x20=FIRST LEVEL BITMAP BLOCK
Dump of First Level Bitmap Block
--------------------------------
nbits : 4 nranges: 2 parent dba: 0x0680000a poffset: 0
unformatted: 13 total: 16 first useful block: 3
owning instance : 1
instance ownership changed at
Last successful Search
Freeness Status: nf1 0 nf2 0 nf3 0 nf4 0
Extent Map Block Offset: 4294967295
First free datablock : 3
Bitmap block lock opcode 0
Locker xid: : 0x0000.000.00000000
Highwater:: 0x0680000c ext#: 0 blk#: 3 ext size: 8
#blocks in seg. hdr's freelists: 0
#blocks below: 0
mapblk 0x00000000 offset: 0
HWM Flag: HWM Set
--------------------------------------------------------
DBA Ranges :
--------------------------------------------------------
0x06800009 Length: 8 Offset: 0
0x06800011 Length: 8 Offset: 8
[color=red]0:Metadata 1:Metadata 2:Metadata 3:unformatted
4:unformatted 5:unformatted 6:unformatted 7:unformatted
8:unformatted 9:unformatted 10:unformatted 11:unformatted
12:unformatted 13:unformatted 14:unformatted 15:unformatted [/color]
--------------------------------------------------------
End dump data blocks tsn: 6 file#: 7 minblk 9 maxblk 9
Start dump data blocks tsn: 6 file#: 7 minblk 10 maxblk 10
buffer tsn: 6 rdba: 0x0680000a (7/10)
scn: 0x0000.00181a39 seq: 0x01 flg: 0x04 tail: 0x1a392101
frmt: 0x02 chkval: 0x2738 type: 0x21=SECOND LEVEL BITMAP BLOCK
Dump of Second Level Bitmap Block
number: 8 nfree: 8 ffree: 0 pdba: 0x0680000b
opcode:0
xid:
L1 Ranges :
--------------------------------------------------------
[color=red]0x06800009 Free: 5 Inst: 1
0x06800019 Free: 5 Inst: 1
0x06800029 Free: 5 Inst: 1
0x06800039 Free: 5 Inst: 1
0x06800049 Free: 5 Inst: 1
0x06800059 Free: 5 Inst: 1
0x06800069 Free: 5 Inst: 1
0x06800079 Free: 5 Inst: 1 [/color]
--------------------------------------------------------
End dump data blocks tsn: 6 file#: 7 minblk 10 maxblk 10
Start dump data blocks tsn: 6 file#: 7 minblk 11 maxblk 11
buffer tsn: 6 rdba: 0x0680000b (7/11)
scn: 0x0000.00181a3d seq: 0x01 flg: 0x04 tail: 0x1a3d2301
frmt: 0x02 chkval: 0x4904 type: 0x23=PAGETABLE SEGMENT HEADER
Extent Control Header
-----------------------------------------------------------------
Extent Header:: spare1: 0 spare2: 0 #extents: 16 #blocks: 128
last map 0x00000000 #maps: 0 offset: 2716
[color=red]Highwater:: 0x0680000c[/color] ext#: 0 blk#: 3 ext size: 8
#blocks in seg. hdr's freelists: 0
#blocks below: 0
mapblk 0x00000000 offset: 0
Unlocked
--------------------------------------------------------
Low HighWater Mark :
[color=red]Highwater:: 0x0680000c [/color] ext#: 0 blk#: 3 ext size: 8
#blocks in seg. hdr's freelists: 0
#blocks below: 0
mapblk 0x00000000 offset: 0
Level 1 BMB for High HWM block: 0x06800009
Level 1 BMB for Low HWM block: 0x06800009
--------------------------------------------------------
Segment Type: 1 nl2: 1 blksz: 8192 fbsz: 0
L2 Array start offset: 0x00001434
First Level 3 BMB: 0x00000000
L2 Hint for inserts: 0x0680000a
[color=red]Last Level 1 BMB: 0x06800079
Last Level II BMB: 0x0680000a
Last Level III BMB: 0x00000000 [/color]
Map Header:: next 0x00000000 #extents: 16 obj#: 29929 flag: 0x20000000
Extent Map
-----------------------------------------------------------------
0x06800009 length: 8
0x06800011 length: 8
0x06800019 length: 8
0x06800021 length: 8
0x06800029 length: 8
0x06800031 length: 8
0x06800039 length: 8
0x06800041 length: 8
0x06800049 length: 8
0x06800051 length: 8
0x06800059 length: 8
0x06800061 length: 8
0x06800069 length: 8
0x06800071 length: 8
0x06800079 length: 8
0x06800081 length: 8
Auxillary Map
--------------------------------------------------------
[color=red]Extent 0 : L1 dba: 0x06800009 Data dba: 0x0680000c
Extent 1 : L1 dba: 0x06800009 Data dba: 0x06800011
Extent 2 : L1 dba: 0x06800019 Data dba: 0x0680001a
Extent 3 : L1 dba: 0x06800019 Data dba: 0x06800021
Extent 4 : L1 dba: 0x06800029 Data dba: 0x0680002a
Extent 5 : L1 dba: 0x06800029 Data dba: 0x06800031
Extent 6 : L1 dba: 0x06800039 Data dba: 0x0680003a
Extent 7 : L1 dba: 0x06800039 Data dba: 0x06800041
Extent 8 : L1 dba: 0x06800049 Data dba: 0x0680004a
Extent 9 : L1 dba: 0x06800049 Data dba: 0x06800051
Extent 10 : L1 dba: 0x06800059 Data dba: 0x0680005a
Extent 11 : L1 dba: 0x06800059 Data dba: 0x06800061
Extent 12 : L1 dba: 0x06800069 Data dba: 0x0680006a
Extent 13 : L1 dba: 0x06800069 Data dba: 0x06800071
Extent 14 : L1 dba: 0x06800079 Data dba: 0x0680007a
Extent 15 : L1 dba: 0x06800079 Data dba: 0x06800081 [/color]
--------------------------------------------------------
Second Level Bitmap block DBAs
--------------------------------------------------------
DBA 1: 0x0680000a
End dump data blocks tsn: 6 file#: 7 minblk 11 maxblk 11
从这里,我们能获得什么信息?
这个是很重要的。
分析块9,这个块叫FIRST LEVEL BITMAP BLOCK。我们可以看到,这里保留了16个块的信息(注意,不是16个区间的信息),也就是说,这个段头块,它记录的是块的使用信息,开始16个块中间有3个块是段头(Metadata,再一次证明也3个段头的保留),不能被使用,其它的都是未使用的块(unformatted)还有13个。
问题?为什么这里只保留16个块的信息呢?这需要我们进一步研究(往下看)
分析块10,叫SECOND LEVEL BITMAP BLOCK。这个就比较有意思了,记录了可能出现的类似于块9的块出现的块地址(叫 BMB DBA)。刚才在上面不是说了吗,块9只能记录16个块的信息,那16个块之后的信息怎么办?BMB段采用了分布的策略,在第25个块的地方,oracle将增加一个新的块用来记录下16个块(等会儿看测试),那么块10记录的就是这些块的地址了,如:
0x06800019 Free: 5 Inst: 1 代表下一个块的地址是19(十六进制),其实是就是十进制的25。那么我们想象,再下一个是25+16=41。应当是十六进制的29,再查看块10的内容,大家可以知道这个块的作用了吧,这个块的地址是随表的增加而增加的。
再看块11,这里就是区间地图了,这里主要记录了表的16个区间的分布地址。可以看到其实在ASSM的表里面,取消了原来的freelist(全部放在段头),其实增加了很多块来管理块的数据,这些块不再分布在块的头部,而是分布在表的内部,每隔16个块(这个数目与不同的环境可能有差别),就有一个块来记录下16个块的数据保留的情况。
好,到这里了,我们开始插入数据,进一步说明情况。
SQL>insert into demotab
select rownum from dba_objects;
28985 rows inserted;
然后我们运行
SQL> exec show_space('demotab');
Total Blocks............................128
Total Bytes.............................1048576
Unused Blocks...........................72
Unused Bytes............................589824
Last Used Ext FileId....................26
Last Used Ext BlockId...................56
Last Used Block.........................8
这里有一个新的过程,用于专门分析自动段管理的段中的块的组成
declare
v_unformatted_blocks number;
v_unformatted_bytes number;
v_fs1_blocks number;
v_fs1_bytes number;
v_fs2_blocks number;
v_fs2_bytes number;
v_fs3_blocks number;
v_fs3_bytes number;
v_fs4_blocks number;
v_fs4_bytes number;
v_full_blocks number;
v_full_bytes number;
begin
dbms_space.space_usage ('SYS', 'DEMOTAB', 'TABLE', v_unformatted_blocks,
v_unformatted_bytes, v_fs1_blocks, v_fs1_bytes, v_fs2_blocks, v_fs2_bytes,
v_fs3_blocks, v_fs3_bytes, v_fs4_blocks, v_fs4_bytes, v_full_blocks, v_full_bytes);
dbms_output.put_line('Unformatted Blocks = '||v_unformatted_blocks);
dbms_output.put_line('FS1 Blocks = '||v_fs1_blocks);
dbms_output.put_line('FS2 Blocks = '||v_fs2_blocks);
dbms_output.put_line('FS3 Blocks = '||v_fs3_blocks);
dbms_output.put_line('FS4 Blocks = '||v_fs4_blocks);
dbms_output.put_line('Full Blocks = '||v_full_blocks);
end;/
Unformatted Blocks = 0
FS1 Blocks = 1
FS2 Blocks = 0
FS3 Blocks = 0
FS4 Blocks = 6
Full Blocks = 43
PL/SQL procedure successfully completed
在这里
FS1表示0-25%空闲空间的块
FS2表示25-50%空闲空间的块
FS3表示50-75%空闲空间的块
FS4表示 75-100%空闲空间的块
这里我们能看到什么呢? 可以看到的是,
Total Blocks............................128
Unused Blocks...........................72
就是说,我们这次插入用了128-72=56个块。
但是看下面的数据,也就是数据块只有1+6+43=50个,还有6个的差别在哪里呢?我们已知的就是段头有3个,那还有3个应当就是分布在表中的位图块了(假定)。我们进一步分析。
IXDBA.NET社区论坛
用了56个块,其实就是7个区间,7个区间,每个位图块只能管理16个块(2个区间),这里应当用到了4个位图块才能够管理过来,4个中有一个属于段头的3个,那正好是50+3+3=56=128-72了。我们进一步分析。
再看那段头变成什么样了?
Start dump data blocks tsn: 6 file#: 7 minblk 9 maxblk 9
buffer tsn: 6 rdba: 0x06800009 (7/9)
scn: 0x0000.0018b7ca seq: 0x2d flg: 0x00 tail: 0xb7ca202d
frmt: 0x02 chkval: 0x0000 type: 0x20=FIRST LEVEL BITMAP BLOCK
Dump of First Level Bitmap Block
--------------------------------
nbits : 4 nranges: 2 parent dba: 0x0680000a poffset: 0
[color=red]unformatted: 0 total: 16 first useful block: 3 [/color]
owning instance : 1
instance ownership changed at 08/19/2003 10:41:42
Last successful Search 08/19/2003 10:41:42
Freeness Status: nf1 0 nf2 0 nf3 0 nf4 0
Extent Map Block Offset: 4294967295
First free datablock : 16
Bitmap block lock opcode 0
Locker xid: : 0x0000.000.00000000
Highwater:: 0x00000000 ext#: 0 blk#: 0 ext size: 0
#blocks in seg. hdr's freelists: 0
#blocks below: 0
mapblk 0x00000000 offset: 0
HWM Flag: Not Set
--------------------------------------------------------
DBA Ranges :
--------------------------------------------------------
0x06800009 Length: 8 Offset: 0
0x06800011 Length: 8 Offset: 8
[color=red]0:Metadata 1:Metadata 2:Metadata 3:FULL
4:FULL 5:FULL 6:FULL 7:FULL
8:FULL 9:FULL 10:FULL 11:FULL
12:FULL 13:FULL 14:FULL 15:FULL [/color]
--------------------------------------------------------
End dump data blocks tsn: 6 file#: 7 minblk 9 maxblk 9
*** 2003-08-19 11:10:10.000
Start dump data blocks tsn: 6 file#: 7 minblk 10 maxblk 10
buffer tsn: 6 rdba: 0x0680000a (7/10)
scn: 0x0000.0018b7cb seq: 0x07 flg: 0x00 tail: 0xb7cb2107
frmt: 0x02 chkval: 0x0000 type: 0x21=SECOND LEVEL BITMAP BLOCK
Dump of Second Level Bitmap Block
number: 8 nfree: 5 ffree: 3 pdba: 0x0680000b
opcode:0
xid:
L1 Ranges :
--------------------------------------------------------
[color=red]0x06800009 Free: 1 Inst: 1
0x06800019 Free: 1 Inst: 1
0x06800029 Free: 1 Inst: 1 [/color]
0x06800039 Free: 5 Inst: 1
0x06800049 Free: 5 Inst: 1
0x06800059 Free: 5 Inst: 1
0x06800069 Free: 5 Inst: 1
0x06800079 Free: 5 Inst: 1
--------------------------------------------------------
End dump data blocks tsn: 6 file#: 7 minblk 10 maxblk 10
Start dump data blocks tsn: 6 file#: 7 minblk 11 maxblk 11
buffer tsn: 6 rdba: 0x0680000b (7/11)
scn: 0x0000.0018b7cb seq: 0x03 flg: 0x00 tail: 0xb7cb2303
frmt: 0x02 chkval: 0x0000 type: 0x23=PAGETABLE SEGMENT HEADER
Extent Control Header
-----------------------------------------------------------------
Extent Header:: spare1: 0 spare2: 0 #extents: 16 #blocks: 128
last map 0x00000000 #maps: 0 offset: 2716
[color=red]Highwater:: 0x06800041 [/color] ext#: 6 blk#: 8 ext size: 8
#blocks in seg. hdr's freelists: 0
#blocks below: 50
mapblk 0x00000000 offset: 6
Unlocked
--------------------------------------------------------
Low HighWater Mark :
[color=red]Highwater:: 0x0680000c [/color] ext#: 0 blk#: 3 ext size: 8
#blocks in seg. hdr's freelists: 0
#blocks below: 0
mapblk 0x00000000 offset: 0
Level 1 BMB for High HWM block: 0x06800039
Level 1 BMB for Low HWM block: 0x06800009
--------------------------------------------------------
Segment Type: 1 nl2: 1 blksz: 8192 fbsz: 0
L2 Array start offset: 0x00001434
First Level 3 BMB: 0x00000000
L2 Hint for inserts: 0x0680000a
Last Level 1 BMB: 0x06800079
Last Level II BMB: 0x0680000a
Last Level III BMB: 0x00000000
Map Header:: next 0x00000000 #extents: 16 obj#: 29929 flag: 0x20000000
Extent Map
-----------------------------------------------------------------
0x06800009 length: 8
0x06800011 length: 8
0x06800019 length: 8
0x06800021 length: 8
0x06800029 length: 8
0x06800031 length: 8
0x06800039 length: 8
0x06800041 length: 8
0x06800049 length: 8
0x06800051 length: 8
0x06800059 length: 8
0x06800061 length: 8
0x06800069 length: 8
0x06800071 length: 8
0x06800079 length: 8
0x06800081 length: 8
Auxillary Map
--------------------------------------------------------
Extent 0 : L1 dba: 0x06800009 Data dba: 0x0680000c
Extent 1 : L1 dba: 0x06800009 Data dba: 0x06800011
Extent 2 : L1 dba: 0x06800019 Data dba: 0x0680001a
Extent 3 : L1 dba: 0x06800019 Data dba: 0x06800021
Extent 4 : L1 dba: 0x06800029 Data dba: 0x0680002a
Extent 5 : L1 dba: 0x06800029 Data dba: 0x06800031
Extent 6 : L1 dba: 0x06800039 Data dba: 0x0680003a
Extent 7 : L1 dba: 0x06800039 Data dba: 0x06800041
Extent 8 : L1 dba: 0x06800049 Data dba: 0x0680004a
Extent 9 : L1 dba: 0x06800049 Data dba: 0x06800051
Extent 10 : L1 dba: 0x06800059 Data dba: 0x0680005a
Extent 11 : L1 dba: 0x06800059 Data dba: 0x06800061
Extent 12 : L1 dba: 0x06800069 Data dba: 0x0680006a
Extent 13 : L1 dba: 0x06800069 Data dba: 0x06800071
Extent 14 : L1 dba: 0x06800079 Data dba: 0x0680007a
Extent 15 : L1 dba: 0x06800079 Data dba: 0x06800081
--------------------------------------------------------
Second Level Bitmap block DBAs
--------------------------------------------------------
DBA 1: 0x0680000a
End dump data blocks tsn: 6 file#: 7 minblk 11 maxblk 11
看块9,可以看到,段头的三个块没有动。另外的13个块都是FULL(100%充满)状态。
看块10,可以看到,充分利用的位图块的位置是:
0x06800009 Free: 1 Inst: 1 --对应9
0x06800019 Free: 1 Inst: 1 --对应25
0x06800029 Free: 1 Inst: 1 --对应41
应当还有一个不完全利用的
0x06800039 Free: 5 Inst: 1 --对应57
下面我们证实一下
块25的信息:
Start dump data blocks tsn: 6 file#: 7 minblk 25 maxblk 25
buffer tsn: 6 rdba: 0x06800019 (7/25)
scn: 0x0000.0018b7cb seq: 0x0e flg: 0x04 tail: 0xb7cb200e
frmt: 0x02 chkval: 0x261c type: 0x20=FIRST LEVEL BITMAP BLOCK
Dump of First Level Bitmap Block
--------------------------------
nbits : 4 nranges: 2 parent dba: 0x0680000a poffset: 1
unformatted: 0 total: 16 first useful block: 1
owning instance : 1
instance ownership changed at 08/19/2003 10:41:42
Last successful Search 08/19/2003 10:41:42
Freeness Status: nf1 0 nf2 0 nf3 0 nf4 0
Extent Map Block Offset: 4294967295
First free datablock : 16
Bitmap block lock opcode 0
Locker xid: : 0x0000.000.00000000
Highwater:: 0x00000000 ext#: 0 blk#: 0 ext size: 0
#blocks in seg. hdr's freelists: 0
#blocks below: 0
mapblk 0x00000000 offset: 0
HWM Flag: Not Set
--------------------------------------------------------
DBA Ranges :
--------------------------------------------------------
0x06800019 Length: 8 Offset: 0
0x06800021 Length: 8 Offset: 8
[color=red]0:Metadata 1:FULL 2:FULL 3:FULL
4:FULL 5:FULL 6:FULL 7:FULL
8:FULL 9:FULL 10:FULL 11:FULL
12:FULL 13:FULL 14:FULL 15:FULL [/color]
--------------------------------------------------------
End dump data blocks tsn: 6 file#: 7 minblk 25 maxblk 25
块41的信息
Start dump data blocks tsn: 6 file#: 7 minblk 41 maxblk 41
buffer tsn: 6 rdba: 0x06800029 (7/41)
scn: 0x0000.0018b7cb seq: 0x35 flg: 0x04 tail: 0xb7cb2035
frmt: 0x02 chkval: 0x260f type: 0x20=FIRST LEVEL BITMAP BLOCK
Dump of First Level Bitmap Block
--------------------------------
nbits : 4 nranges: 2 parent dba: 0x0680000a poffset: 2
unformatted: 0 total: 16 first useful block: 1
owning instance : 1
instance ownership changed at 08/19/2003 10:41:42
Last successful Search 08/19/2003 10:41:42
Freeness Status: nf1 0 nf2 0 nf3 0 nf4 0
Extent Map Block Offset: 4294967295
First free datablock : 16
Bitmap block lock opcode 0
Locker xid: : 0x0000.000.00000000
Highwater:: 0x00000000 ext#: 0 blk#: 0 ext size: 0
#blocks in seg. hdr's freelists: 0
#blocks below: 0
mapblk 0x00000000 offset: 0
HWM Flag: Not Set
--------------------------------------------------------
DBA Ranges :
--------------------------------------------------------
0x06800029 Length: 8 Offset: 0
0x06800031 Length: 8 Offset: 8
[color=red]0:Metadata 1:FULL 2:FULL 3:FULL
4:FULL 5:FULL 6:FULL 7:FULL
8:FULL 9:FULL 10:FULL 11:FULL
12:FULL 13:FULL 14:FULL 15:FULL [/color]
--------------------------------------------------------
End dump data blocks tsn: 6 file#: 7 minblk 41 maxblk 41
块57的信息
Start dump data blocks tsn: 6 file#: 7 minblk 57 maxblk 57
buffer tsn: 6 rdba: 0x06800039 (7/57)
scn: 0x0000.0018b7cb seq: 0x04 flg: 0x04 tail: 0xb7cb2004
frmt: 0x02 chkval: 0x27d2 type: 0x20=FIRST LEVEL BITMAP BLOCK
Dump of First Level Bitmap Block
--------------------------------
nbits : 4 nranges: 2 parent dba: 0x0680000a poffset: 3
unformatted: 8 total: 16 first useful block: 1
owning instance : 1
instance ownership changed at 08/19/2003 10:41:42
Last successful Search 08/19/2003 10:41:42
Freeness Status: nf1 1 nf2 0 nf3 0 nf4 6
Extent Map Block Offset: 4294967295
First free datablock : 1
Bitmap block lock opcode 0
Locker xid: : 0x0000.000.00000000
Highwater:: 0x06800041 ext#: 6 blk#: 8 ext size: 8
#blocks in seg. hdr's freelists: 0
#blocks below: 50
mapblk 0x00000000 offset: 6
HWM Flag: HWM Set
--------------------------------------------------------
DBA Ranges :
--------------------------------------------------------
0x06800039 Length: 8 Offset: 0
0x06800041 Length: 8 Offset: 8
[color=red]0:Metadata 1:75-100% free 2:75-100% free 3:75-100% free
4:75-100% free 5:75-100% free 6:75-100% free 7:0-25% free
8:unformatted 9:unformatted 10:unformatted 11:unformatted
12:unformatted 13:unformatted 14:unformatted 15:unformatted [/color]
--------------------------------------------------------
End dump data blocks tsn: 6 file#: 7 minblk 57 maxblk 57
块9:2个段头+1个位图+13个FULL
块25:1个位图+15个FULL
块41:1个位图+15个FULL
块57:1个位图+6个75-100% free+1个0-25% free
大家可以看到正好满足上面的:
FS1 Blocks = 1
FS2 Blocks = 0
FS3 Blocks = 0
FS4 Blocks = 6
Full Blocks = 43
到这里,大家也明白了
3*16+8=56=1+6+43+3(段头,其中有一个是BMB)+3(BMB)
最后,我们讨论高水点的确定。
到这里,大家该知道高水点的位置是多少了吧,应该是56+8(文件头)+1=65(这个1表示在数据块之上,因为块从1开始而不是从0开始)。但是看我们的块11,怎么解释这个呢?
Highwater:: 0x06800041 ext#: 6 blk#: 8 ext size: 8
#blocks in seg. hdr's freelists: 0
#blocks below: 50
mapblk 0x00000000 offset: 6
Unlocked
--------------------------------------------------------
Low HighWater Mark :
[color=red]Highwater:: 0x0680000c [/color] ext#: 0 blk#: 3 ext size: 8
其中有两个Highwater,第一个记录了真正的高水点,H41,就是十进制65
第二个表示底的高水点,从哪里开始,很明显,从12(十六进制的c)
个块开始(前面是8个文件头+3个段头)
其实,我们从最后一个位图块(57)的dump中也可以看到这样的信息
Locker xid: : 0x0000.000.00000000
[color=red]Highwater:: 0x06800041 [/color] ext#: 6 blk#: 8 ext size: 8
少有的好文章呀 |
两个问题 | Copy to clipboard |
Posted by: overmars Posted on: 2003-08-26 16:27 1、有点不懂你的“大家该知道高水点的位置是多少了吧,应该是56+8(文件头)+1=65”中的“1”是怎么得来的呢?其实通过dba_extents可以知道,表是从第9个块开始写数据的。HWM=56+9=65 2、你说的这个情况只是适用于0-15个extents(每个extents大小是64K,8个8K的数据块),从第16个extents开始没有extents的大小是128个8K的数据块,这时它的管理是每128个块中包含2个块来做空间管理。 |
回复: ASSM内部存储研究大揭密 | Copy to clipboard |
Posted by: overmars Posted on: 2003-08-26 16:37 FS1 Blocks = 1 FS2 Blocks = 0 FS3 Blocks = 0 FS4 Blocks = 17 Full Blocks = 352 PL/SQL 过程已成功完成。 在这里 FS1表示0-25%空闲空间的块 FS2表示25-50%空闲空间的块 FS3表示50-75%空闲空间的块 IXDBA.NET技术社区 FS4表示 75-100%空闲空间的块 SQL> exec show_space('ASSM','AUTO'); Total Blocks............................384 Total Bytes.............................3145728 Unused Blocks...........................0 Unused Bytes............................0 Last Used Ext FileId....................5 Last Used Ext BlockId...................264 Last Used Block.........................128 PL/SQL 过程已成功完成。 SQL> select extent_id,block_id,blocks from dba_extents where segment_name='ASSM' EXTENT_ID BLOCK_ID BLOCKS ---------- ---------- ---------- 0 9 8 1 17 8 2 25 8 3 33 8 4 41 8 5 49 8 6 57 8 7 65 8 8 73 8 9 81 8 10 89 8 EXTENT_ID BLOCK_ID BLOCKS ---------- ---------- ---------- 11 97 8 12 105 8 13 113 8 14 121 8 15 129 8 16 137 128 17 265 128 已选择18行。 *** SESSION ID:(7.3) 2003-08-26 15:22:23.428 Start dump data blocks tsn: 8 file#: 5 minblk 137 maxblk 137 buffer tsn: 8 rdba: 0x01400089 (5/137) scn: 0x0000.0016c1d5 seq: 0x0d flg: 0x04 tail: 0xc1d5200d frmt: 0x02 chkval: 0x2732 type: 0x20=FIRST LEVEL BITMAP BLOCK Dump of First Level Bitmap Block -------------------------------- nbits : 4 nranges: 1 parent dba: 0x0140000a poffset: 8 unformatted: 0 total: 64 first useful block: 2 owning instance : 1 instance ownership changed at 08/26/2003 10:27:09 Last successful Search 08/26/2003 10:27:09 Freeness Status: nf1 0 nf2 0 nf3 0 nf4 0 Extent Map Block Offset: 4294967295 First free datablock : 64 Bitmap block lock opcode 0 Locker xid: : 0x0000.000.00000000 Highwater:: 0x00000000 ext#: 0 blk#: 0 ext size: 0 #blocks in seg. hdr's freelists: 0 #blocks below: 0 mapblk 0x00000000 offset: 0 HWM Flag: Not Set -------------------------------------------------------- DBA Ranges : -------------------------------------------------------- 0x01400089 Length: 64 Offset: 0 0:Metadata 1:Metadata 2:FULL 3:FULL 4:FULL 5:FULL 6:FULL 7:FULL 8:FULL 9:FULL 10:FULL 11:FULL 12:FULL 13:FULL 14:FULL 15:FULL 16:FULL 17:FULL 18:FULL 19:FULL 20:FULL 21:FULL 22:FULL 23:FULL 24:FULL 25:FULL 26:FULL 27:FULL 28:FULL 29:FULL 30:FULL 31:FULL 32:FULL 33:FULL 34:FULL 35:FULL 36:FULL 37:FULL 38:FULL 39:FULL 40:FULL 41:FULL 42:FULL 43:FULL 44:FULL 45:FULL 46:FULL 47:FULL 48:FULL 49:FULL 50:FULL 51:FULL 52:FULL 53:FULL 54:FULL 55:FULL 56:FULL 57:FULL 58:FULL 59:FULL 60:FULL 61:FULL 62:FULL 63:FULL -------------------------------------------------------- End dump data blocks tsn: 8 file#: 5 minblk 137 maxblk 137 *** 2003-08-26 15:28:34.351 Start dump data blocks tsn: 8 file#: 5 minblk 138 maxblk 138 buffer tsn: 8 rdba: 0x0140008a (5/138) scn: 0x0000.0016c1db seq: 0x02 flg: 0x04 tail: 0xc1db2002 frmt: 0x02 chkval: 0x2772 type: 0x20=FIRST LEVEL BITMAP BLOCK Dump of First Level Bitmap Block -------------------------------- nbits : 4 nranges: 1 parent dba: 0x0140000a poffset: 9 unformatted: 0 total: 64 first useful block: 0 owning instance : 1 instance ownership changed at 08/26/2003 10:27:12 Last successful Search 08/26/2003 10:27:12 Freeness Status: nf1 0 nf2 0 nf3 0 nf4 0 Extent Map Block Offset: 4294967295 First free datablock : 64 Bitmap block lock opcode 0 Locker xid: : 0x0000.000.00000000 Highwater:: 0x00000000 ext#: 0 blk#: 0 ext size: 0 #blocks in seg. hdr's freelists: 0 #blocks below: 0 mapblk 0x00000000 offset: 0 HWM Flag: Not Set -------------------------------------------------------- DBA Ranges : -------------------------------------------------------- 0x014000c9 Length: 64 Offset: 0 0:FULL 1:FULL 2:FULL 3:FULL 4:FULL 5:FULL 6:FULL 7:FULL 8:FULL 9:FULL 10:FULL 11:FULL 12:FULL 13:FULL 14:FULL 15:FULL 16:FULL 17:FULL 18:FULL 19:FULL 20:FULL 21:FULL 22:FULL 23:FULL 24:FULL 25:FULL 26:FULL 27:FULL 28:FULL 29:FULL 30:FULL 31:FULL 32:FULL 33:FULL 34:FULL 35:FULL 36:FULL 37:FULL 38:FULL 39:FULL 40:FULL 41:FULL 42:FULL 43:FULL 44:FULL 45:FULL 46:FULL 47:FULL 48:FULL 49:FULL 50:FULL 51:FULL 52:FULL 53:FULL 54:FULL 55:FULL 56:FULL 57:FULL 58:FULL 59:FULL 60:FULL 61:FULL 62:FULL 63:FULL -------------------------------------------------------- End dump data blocks tsn: 8 file#: 5 minblk 138 maxblk 138 *** 2003-08-26 10:40:27.307 Start dump data blocks tsn: 8 file#: 5 minblk 265 maxblk 265 buffer tsn: 8 rdba: 0x01400109 (5/265) scn: 0x0000.0016c1df seq: 0x1c flg: 0x00 tail: 0xc1df201c frmt: 0x02 chkval: 0x0000 type: 0x20=FIRST LEVEL BITMAP BLOCK Dump of First Level Bitmap Block -------------------------------- nbits : 4 nranges: 1 parent dba: 0x0140000a poffset: 10 unformatted: 0 total: 64 first useful block: 2 owning instance : 1 instance ownership changed at 08/26/2003 10:27:13 Last successful Search 08/26/2003 10:27:13 Freeness Status: nf1 0 nf2 0 nf3 0 nf4 0 Extent Map Block Offset: 4294967295 First free datablock : 64 Bitmap block lock opcode 0 Locker xid: : 0x0000.000.00000000 Highwater:: 0x00000000 ext#: 0 blk#: 0 ext size: 0 #blocks in seg. hdr's freelists: 0 #blocks below: 0 mapblk 0x00000000 offset: 0 HWM Flag: Not Set -------------------------------------------------------- DBA Ranges : -------------------------------------------------------- 0x01400109 Length: 64 Offset: 0 0:Metadata 1:Metadata 2:FULL 3:FULL--- 4:FULL 5:FULL 6:FULL 7:FULL 8:FULL 9:FULL 10:FULL 11:FULL 12:FULL 13:FULL 14:FULL 15:FULL 16:FULL 17:FULL 18:FULL 19:FULL 20:FULL 21:FULL 22:FULL 23:FULL 24:FULL 25:FULL 26:FULL 27:FULL 28:FULL 29:FULL 30:FULL 31:FULL 32:FULL 33:FULL 34:FULL 35:FULL 36:FULL 37:FULL 38:FULL 39:FULL 40:FULL 41:FULL 42:FULL 43:FULL 44:FULL 45:FULL 46:FULL 47:FULL 48:FULL 49:FULL 50:FULL 51:FULL 52:FULL 53:FULL 54:FULL 55:FULL 56:FULL 57:FULL 58:FULL 59:FULL 60:FULL 61:FULL 62:FULL 63:FULL -------------------------------------------------------- End dump data blocks tsn: 8 file#: 5 minblk 265 maxblk 265 *** 2003-08-26 10:41:05.642 Start dump data blocks tsn: 8 file#: 5 minblk 266 maxblk 266 buffer tsn: 8 rdba: 0x0140010a (5/266) scn: 0x0000.0016c1e3 seq: 0x06 flg: 0x00 tail: 0xc1e32006 frmt: 0x02 chkval: 0x0000 type: 0x20=FIRST LEVEL BITMAP BLOCK Dump of First Level Bitmap Block -------------------------------- nbits : 4 nranges: 1 parent dba: 0x0140000a poffset: 11 unformatted: 0 total: 64 first useful block: 0 owning instance : 1 instance ownership changed at 08/26/2003 10:27:14 Last successful Search 08/26/2003 10:27:14 Freeness Status: nf1 1 nf2 0 nf3 0 nf4 17 Extent Map Block Offset: 4294967295 First free datablock : 0 Bitmap block lock opcode 0 Locker xid: : 0x0000.000.00000000 Highwater:: 0x01400189 ext#: 17 blk#: 128 ext size: 128 #blocks in seg. hdr's freelists: 0 #blocks below: 370 mapblk 0x00000000 offset: 17 HWM Flag: HWM Set -------------------------------------------------------- DBA Ranges : -------------------------------------------------------- 0x01400149 Length: 64 Offset: 0 0:75-100% free 1:FULL 2:FULL 3:0-25% free 4:75-100% free 5:FULL 6:FULL 7:75-100% free 8:FULL 9:FULL 10:FULL 11:75-100% free 12:FULL 13:FULL 14:FULL 15:75-100% free 16:FULL 17:FULL 18:FULL 19:75-100% free 20:FULL 21:FULL 22:FULL 23:75-100% free 24:FULL 25:FULL 26:FULL 27:75-100% free 28:FULL 29:FULL 30:FULL 31:75-100% free 32:FULL 33:FULL 34:FULL 35:75-100% free 36:FULL 37:FULL 38:FULL 39:75-100% free 40:FULL 41:FULL 42:FULL 43:75-100% free 44:FULL 45:FULL 46:FULL 47:75-100% free 48:FULL 49:FULL 50:FULL 51:75-100% free 52:FULL 53:FULL 54:FULL 55:75-100% free 56:FULL 57:FULL 58:FULL 59:75-100% free 60:FULL 61:FULL 62:FULL 63:75-100% free -------------------------------------------------------- End dump data blocks tsn: 8 file#: 5 minblk 266 maxblk 266 可以看到从第16号extents开始每128个块中有2个块来管理位图的信息,节省了很多的空间。 |
overmars wrote: 1、有点不懂你的“大家该知道高水点的位置是多少了吧,应该是56+8(文件头)+1=65”中的“1”是怎么得来的呢?其实通过dba_extents可以知道,表是从第9个块开始写数据的。HWM=56+9=65 因为HWM的是在数据上面的一个块,当然加1了。 如一个数据都没有的时候, DMT的HWM是1+1+1=3 LMT一般是8+1+1=10 ASSM一般是8+3+1=12 |
回复: ASSM内部存储研究大揭密 | Copy to clipboard |
Posted by: piner Posted on: 2003-08-26 17:21 的确是这样,但不完全是这样 从dump出来的块10记录的位图位置也可以看到这一变化 可以看到下面的变化,18->20->28->30 -------------------------------------------------------------------------------------------------- [$nbsp][$nbsp][$nbsp]0x06800009 Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x06800019 Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x06800029 Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x06800039 Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x06800049 Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x06800059 Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x06800069 Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x06800079 Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x06800109 Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x0680010a Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x06800189 Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x0680018a Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x06800209 Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x0680020a Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x06800289 Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x0680028a Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x06800309 Free: 1 Inst: 1 [$nbsp][$nbsp][$nbsp]0x0680030a Free: 5 Inst: 1 这里我们对比以上的块10的内容,还可以看到,条目是不断增加的,也就是说,每增加一个BMB,就在该块中增加一个条目 |
回复: 回复: ASSM内部存储研究大揭密 | Copy to clipboard |
Posted by: jlandzpa Posted on: 2003-09-11 10:32 如果加上参考文献,就更加完备了. parrotao wrote: 少有的好文章呀 |