Oracle 高水位(HWM: High Water Mark)

本文详细介绍了Oracle数据库中的高水位(HWM)概念,包括逻辑存储管理的4个层次:表空间、段、区和块。高水位标记(HWM)用于区分已使用和未使用的数据块,其在数据插入时会上移,删除时不下降。文章讨论了HWM如何影响全表扫描性能,并提供了调整HWM的各种方法,如TRUNCATE、ALTER TABLE SHRINK SPACE等。此外,还提到了Oracle 10g引入的低水位标记,用于管理自动段空间管理中的已格式化块。
摘要由CSDN通过智能技术生成

准备知识:ORACLE的逻辑存储管理.

       ORACLE在逻辑存储上分4个粒度: 表空间, 段, 区 和 块.

 

       1.1 : 是粒度最小的存储单位,现在标准的块大小是8K,ORACLE每一次I/O操作也是按块来操作的,也就是说当ORACLE从数据文件读数据时,是读取多少个块,而不是多少行. 每一个Block里可以包含多个row.

 

       1.2 由一系列相邻的块而组成,这也ORACLE空间分配的基本单位,举个例子来说,当我们创建一个表Dave时,首先ORACLE会分配一区的空间给这个表,随着不断的INSERT数据到Dave,原来的这个区容不下插入的数据时,ORACLE是以区为单位进行扩展的,也就是说再分配多少个区给Dave,而不是多少个块.

 

       1.3 : 是由一系列的区所组成, 一般来说, 当创建一个对象时(表,索引),就会分配一个段给这个对象. 所以从某种意义上来说,段就是某种特定的数据.如CREATE TABLE Dave,这个段就是数据段,而CREATE INDEX ON Dave(NAME), ORACLE同样会分配一个段给这个索引,但这是一个索引段了.查询段的信息可以通过数据字典: SELECT * FROM USER_SEGMENTS来获得.

 

       1.4 表空间: 包含段,区及块.表空间的数据物理上储存在其所在的数据文件中.一个数据库至少要有一个表空间.

 

表空间(tableSpace) (segment) 盘区(extent) (block) 关系

http://blog.csdn.net/tianlesoftware/archive/2009/12/08/4962476.aspx

 

 

       当我们创建了一个表,即使我没有插入任何一行记录, ORACLE还是给它分配了8个块. 当然这个跟建表语句的INITIAL 参数及MINEXTENTS参数有关. 如:

STORAGE

(

INITIAL 64K

MINEXTENTS 1

MAXEXTENTS UNLIMITED

);

 

       也就是说,在这个对象创建以后,ORACLE至少给它分配一个区,初始大小是64K,一个标准块的大小是8K,刚好是8BLOCK.

 

Oracle Table 创建参数 说明

http://blog.csdn.net/tianlesoftware/archive/2009/12/07/4954417.aspx

 

.  高水线(High Water Mark)

2.1 官网说明如下

http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/logical.htm#CNCPT89022

 

       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.

      

       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.

 

      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 自动段空间管理(ASSM:auto segment space management)

http://blog.csdn.net/tianlesoftware/archive/2009/12/07/4958989.aspx

 

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

1Above the HWM

       These blocks are unformatted and have never been used.

2Below the HWM

       These blocks are in one of the following states:

       (1)Allocated, but currently unformatted and unused

       (2)Formatted and contain data

       (3)Formatted and empty because the data was deleted

 

       Figure 12-23 depicts an ASSM segment as a horizontal series of blocks. At table creation, the HWM is at the beginning of the segment on the left. Because no data has been inserted yet, all blocks in the segment are unformatted and never used.

 

Figure 12-23 HWM at Table Creation

 

       Suppose that a transaction inserts rows into the segment. The database must allocate a group of blocks to hold the r

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值