PCTFREE,PCTUSED

本文详细解析了Oracle数据库中PCTFREE与PCTUSED参数的作用与配置方法,帮助理解如何通过这两个参数来优化数据块空间使用,提高数据库性能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

       For manually managed tablespaces, two space management parameters, PCTFREE and PCTUSED, 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 parameter PCTFREE 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-3illustrates PCTFREE.

     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 aCREATE TABLE 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值