ORALCE的段管理简单说明

简介: 一、高水位线的说明To manage space, Oracle Database tracks the state of blocks in the segment. The high water mark (HWM) is the point in a segment beyond which data blocks are unformatted and have never been used. 为了管理表空间,ORACLEG跟踪块在段中的状态,这个HWM是一个标记,用来说明已经有多少没有使用的数据块分配给这个segment。

一、高水位线的说明

To manage space, Oracle Database tracks the state of blocks in the segment. The high water mark (HWM) is the point in a segment beyond which data blocks are unformatted and have never been used. 为了管理表空间,ORACLEG跟踪块在段中的状态,这个HWM是一个标记,用来说明已经有多少没有使用的数据块分配给这个segment。说明:HWM通常增长的幅度为一次5个数据块,原则上HWM只会增大,不会缩小,即使将表中的数据全部删除,HWM还是为原值,由于这个特点,使HWM很象一个水库的历史最高水位,这也就是HWM的原始含义,当然不能说一个水库没水了,就说该水库的历史最高水位为0。

二、段管理的演变

1、MSSM uses free lists to manage segment space. At table creation, no blocks in the segment are formatted. When a session first inserts rows into the table, the database searches the free list for usable blocks. If the database finds no usable blocks, then it preformats a group of blocks, places them on the free list, and begins inserting data into the blocks. In MSSM, a full table scan reads all blocks below the HWM.

早期数据库的段管理方式:早期ORACLE通过MSSM(Manual Segment Space Management),这种管理方式所有的segment的分配都是统一由数据库的一个free list来进行管理的(可以简单理解为中央集权制),这中段的管理方式效率慢,所以后面就被淘汰了。但是数据库为了向下兼容,11g的时候在创建表空间的时候,还可以选择MSSM的方式进行管理表空间,但是请不要使用;

 

2、ASSM does not use free lists and so must manage space differently. When a session first inserts data into a table, the database formats a single bitmap block instead of preformatting a group of blocks as in MSSM. The bitmap tracks the state of blocks in the segment, taking the place of the free list. The database uses the bitmap to find free blocks and then formats each block before filling it with data. ASSM spread out inserts among blocks to avoid concurrency issues.

从ORACLE 9I开始推出了新的表空间管理方式ASSM(Auto  Segment Space Management),创建段的时候首先创建一个位图,通过位图来跟踪或管理每个分配到对象的块,每个块有多少剩余空间根据位图的状态来确定。当FREELIST中不包含可插入数据块时 HWM默认每次上升5个数据块。

 

3、HWM和LOW HWM

Every data block in an ASSM segment is in one of the following states:

  • Above the HWM(高水位线之上)

    These blocks are unformatted and have never been used.(所有的块都是未格式化和使用的)

  • Below the HWM (高水位线之下)

    These blocks are in one of the following states:

    • Allocated, but currently unformatted and unused(已分配,但是未格式化且未使用)
    • Formatted and contain data(格式化并且有数据)
    • Formatted and empty because the data was deleted(格式化但是由于原先的数据被删除,所以是没数据的)

The low HWM is important in a full table scan. Because blocks below the HWM are formatted only when used, some blocks could be unformatted,. For this reason, the database reads the bitmap block to obtain the location of the low HWM. The database reads all  blocks up to the low HWM because they are known to be formatted, and then carefully reads only the formatted blocks between the low HWM and the HWM.

Assume that a new transaction inserts rows into the table, but the bitmap indicates that insufficient free space exists under the HWM. In Figure 12-26, the database advances the HWM to the right, allocating a new group of unformatted blocks.

三、总结

ASSM的引入进一步减轻了DBA的工作,但是如果一个表进行大量的删除以后,在做表的全表扫描就会以下问题,因为HWM和LHWM在插入数据时,当现有空间不足而进行空间的扩展时会向上移,但删除数据时不会往下移,所以问题就产生了.当用户发出一个全表扫描时,ORACLE 始终必须从段一直扫描到 HWM,即使它什么也没有发现。该任务延长了全表扫描的时间。

所以当一个表进行大量的删除之后,需要进行相应的收缩工作,从而保证了全表扫描的性能;

..........................................................................................................................................................................................................................本文作者:JOHN

ORACLE技术博客:ORACLE 猎人笔记               数据库技术群:367875324 (请备注ORACLE管理 )  

................................................................................................................................................................................................................................

相关文章
|
6天前
|
存储 Oracle 关系型数据库
Oracle的段:深入数据段与日志段的奥秘
【4月更文挑战第19天】Oracle数据库中的数据段和日志段是存储管理的核心。数据段存储表和索引的实际数据,随数据增长动态调整;日志段记录变更历史,保障数据完整性和恢复。两者协同工作,确保数据库稳定性和并发控制。了解和优化它们的配置能提升数据库性能和可靠性,为业务发展提供支持。
|
6天前
|
存储 关系型数据库 MySQL
MySQL表空间结构与页、区、段的定义
一、概念引入 1、页 InnoDB是以页为单位管理存储空间的,在InnoDB中针对不同的目的设计了各种不同类型的页面。如下(省略了FIL_PAGE或FiL_PAGE_TYPE的前缀):
|
SQL Oracle 关系型数据库
|
Oracle 关系型数据库 数据库
|
SQL 缓存 Oracle