PCTFREE,PCTUSED

来源:互联网 发布:python cookbook 编辑:程序博客网 时间:2024/05/19 22:03
       For manually managed tablespaces, two space management parameters, PCTFREE andPCTUSED, enable you to control the use of free space for inserts and updates to the rows in all the data blocks of a particular segment. Specify these parameters when you create or alter a table or cluster (which has its own data segment). You can also specify the storage parameterPCTFREE when creating or altering an index (which has its own index segment).

Note:

      This discussion does not apply to LOB datatypes (BLOB, CLOB, NCLOB, and BFILE). They do not use the PCTFREE storage parameter or free lists.

The PCTFREE Parameter

      The PCTFREE parameter sets the minimum percentage of a data block to bereserved as free space for possible updates to rows that already exist in that block. For example, assume that you specify the following parameter within aCREATE TABLE statement:

PCTFREE 20 

This states that 20% of each data block in this table's data segment be kept free and available for possible updates to the existing rows already within each block. New rows can be added to the row data area, and corresponding information can be added to the variable portions of the overhead area, until the row data and overhead total 80% of the total block size.Figure 2-3illustratesPCTFREE.

     Figure 2-3 PCTFREE

Description of Figure 2-3 follows

The PCTUSED Parameter

      The PCTUSED parameter sets the minimum percentage of a block that can be used for row data plus overhead before new rows are added to the block. After a data block is filled to the limit determined byPCTFREE, Oracle considers the block unavailable for the insertion of new rows until the percentage of that block falls beneath the parameterPCTUSED. Until this value is achieved, Oracle uses the free space of the data block only for updates to rows already contained in the data block. For example, assume that you specify the following parameter in aCREATETABLE statement:

PCTUSED 40 

     In this case, a data block used for this table's data segment is considered unavailable for the insertion of any new rows until the amount of used space in the block falls to 39% or less (assuming that the block's used space has previously reachedPCTFREE).Figure 2-4 illustrates this.

     Figure 2-4 PCTUSED

Description of Figure 2-4 follows


How PCTFREE and PCTUSED Work Together

   PCTFREE and PCTUSED work together to optimize the use of space in the data blocks of the extents within a data segment.Figure 2-5 illustrates the interaction of these two parameters.

       Figure 2-5 Maintaining the Free Space of Data Blocks with PCTFREE and PCTUSED

Description of Figure 2-5 follows

上面的意思是:

      PCTFREE:为一个块保留的空间百分比,表示数据块在什么情况下可以被insert,默认是10,表示当数据块的可用空间低于10%后,就不可以被insert了,只能被用于update;即:当使用一个block时,在达到pctfree之前,该block是一直可以被插入的。

      PCTUSED:是指当块里的数据低于多少百分比时,又可以重新被insert,一般默认是40,即40%,即:当数据低于40%时,又可以写入新的数据。

      注意:如果表空间上启用了ASSM,在建立表的时候,只能指定PCTFREE,否则可用指定PCTFREE和PCTUSED。

      查询pctfree,pctused:select a.table_name, a.pct_free, a.pct_used, a.* from dba_tables a

原创粉丝点击