打印本文 打印本文 关闭窗口 关闭窗口
Oracle Freelist和HWM原理探讨及相关性能优化
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2848  更新时间:2009/4/22 22:05:17  文章录入:mintao  责任编辑:mintao
in seg. hdr''''s freelists: number of blocks in seg. hdr''''s free list
==> #blocks below: number of blocks below HWM
==> mapblk dba: dba of extent map block containing HWM extent
                is 0 if HWM is in the segment header
==> offset:   offset within extent map block
              is the ext# if HWM is in segment header
==> Locked by: if locked by a transaction, the xid is displayed

 

HWM可以说是已经使用过的存储空间和未使用过的存储空间之间的分界线。在表使用过程中,HWM一直向一个方向移动,插入记录时HWM可能会向增加的方向移动,但是删除记录时HWM并不会向相反的方向移动。参见2.4.2。下图显示了某个数据段中HWM的位置情况。

图2.5

HIGH WATER MARK之所以重要是因为它对全表扫描性能的影响。当实施一个全表扫描时,Oracle会读取所有HIGH WATER MARK下的块即使它们是空块。当HIGH WATER MARK 下有很多unused block时实施全表扫描会增加额外的不必要的I/O。它也会在全局共享区中填充很多很多空块。

 

3.分析方法

    存储参数基本上属于oracle internal的东西,因此oralce并没有提供很好的手段来分析。但是对于DBA来说,还是可以通过block dump和DBMS_SPACE等手段来获取部分信息。

3.1 提取block和free list信息

创建dbms_space使用的存储过程show_space

SQL>

create or replace procedure show_space

 ( p_segname in varchar2,

 p_owner in varchar2 default user,

 p_type in varchar2 default ''''TABLE'''',

 p_partition in varchar2 default NULL )

 as

 l_free_blks number;

 l_total_blocks number;

 l_total_bytes number;

 l_unused_blocks number;

 l_unused_bytes number;

 l_LastUsedExtFileId number;

 l_LastUsedExtBlockId number;

 l_last_used_block number;

 procedure p( p_label in varchar2, p_num in number )

 is

 begin

 dbms_output.put_line( rpad(p_label,40,''''.'''') || p_num );

 end;

 begin

 dbms_space.free_blocks

 ( segment_owner => p_owner,

 segment_name => p_segname,

 segment_type => p_type,

 partition_name => p_partition,

 freelist_group_id => 0,

 free_blks => l_free_blks );

 

 dbms_space.unused_space

 ( segment_owner => p_owner,

 segment_name => p_segname,

 segment_type => p_type,

 partition_name => p_partition,

 total_blocks => l_total_blocks,

 total_bytes => l_total_bytes,

 unused_blocks => l_unused_blocks,

 unused_bytes => l_unused_bytes,

 last_used_extent_file_id => l_LastUsedExtFileId,

 last_used_extent_block_id => l_LastUsedExtBlockId,

 last_used_block => l_last_used_block );

 

 p( ''''Free Blocks'''', l_free_blks );

 p( ''''Total Blocks'''', l_total_blocks );

 p( ''''Total Bytes'''', l_total_bytes );

 p( ''''Unused Blocks'''', l_unused_blocks );

 p( ''''Unused Bytes'''', l_unused_bytes );

 p( ''''Last Used Ext FileId'''', l_LastUsedExtFileId );

 p( ''''Last Used Ext BlockId'''', l_LastUsedExtBlockId );

 p( ''''Last Used Block'''', l_last_used_block );

 end;

过程已创建。

 

SQL> create table t1(a char(1000)) storage( freelists 3);

表已创建。

SQL> set serveroutput on;

SQL> exec show_space(''''T1'''');

Free Blocks.............................0       <==Number of blocks on freelist

Total Blocks............................5       <==Total data blocks in segment

Total Bytes.............................20480   <==Total bytes in segment

Unused Blocks..

上一页  [1] [2] [3] [4] [5]  下一页

打印本文 打印本文 关闭窗口 关闭窗口