Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / Oracle selected docs / Database concepts.pdf
Скачиваний:
29
Добавлен:
12.05.2015
Размер:
6.96 Mб
Скачать

PCTFREE, PCTUSED, and Row Chaining

disappear as soon as the tablespace is brought back online and recovered. Oracle automatically creates deferred rollback segments in the SYSTEM tablespace.

High Water Mark

The high water mark is the boundary between used and unused space in a segment. As requests for new free blocks that cannot be satisfied by existing free lists are received, the block to which the high water mark points becomes a used block, and the high water mark is advanced to the next block. In other words, the segment space to the left of the high water mark is used, and the space to the right of it is unused.

Figure B–5 shows a segment consisting of three extents containing 10K, 20K, and 30K of space, respectively. The high water mark is in the middle of the second extent. Thus, the segment contains 20K of used space to the left of the high water mark, and 40K of unused space to the right of the high water mark.

Figure B–5 High Water Mark

 

 

 

UNUSED SPACE = 40K

Segment

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Extent 1

Extent 2

 

Extent 3

10K

20K

 

30K

 

 

 

 

 

 

High

 

 

Water

Mark

PCTFREE, PCTUSED, and Row Chaining

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).

Information on Deprecated Features B-15

PCTFREE, PCTUSED, and Row Chaining

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.

See "LOB Datatypes" on page 12-13 for more information.

The PCTFREE Parameter The PCTFREE parameter sets the minimum percentage of a data block to be reserved as free space for possible updates to rows that already exist in that block. For example, assume that you specify the following parameter within a CREATE 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 B–6 illustrates PCTFREE.

B-16 Oracle9i Database Concepts

PCTFREE, PCTUSED, and Row Chaining

Figure B–6 PCTFREE

Data Block

PCTFREE = 20

20% Free Space

Block allows row inserts until 80% is occupied, leaving 20% free for updates to existing rows in the block

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 by PCTFREE, Oracle considers the block unavailable for the insertion of new rows until the percentage of that block falls below the parameter PCTUSED. 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 a

CREATE 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 reached PCTFREE). Figure B–7 illustrates this.

Information on Deprecated Features B-17

PCTFREE, PCTUSED, and Row Chaining

Figure B–7 PCTUSED

Data Block

PCTUSED = 40

61% Free

Space

No new rows are inserted until amount of used space falls below 40%

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 B–8 illustrates the interaction of these two parameters.

B-18 Oracle9i Database Concepts

PCTFREE, PCTUSED, and Row Chaining

Figure B–8 Maintaining the Free Space of Data Blocks with PCTFREE and PCTUSED

 

 

 

2 Updates to

 

 

 

 

 

 

 

 

 

 

 

 

exisiting rows

 

 

 

use the free

 

1 Rows are

 

space

 

 

reserved in

 

inserted up to

 

the block.

 

80% only,

 

No new rows

 

because

 

can be

 

PCTFREE

 

inserted into

 

specifies that

 

the block

 

20% of the

 

until the

 

block must

 

amount of

 

remain open

 

used

 

for updates of

 

space is 39%

 

existing rows.

 

or less.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4 Rows are

 

 

 

 

 

 

inserted up to

 

 

 

80% only,

 

3 After the

 

because

 

 

PCTFREE

 

amount of

 

specifies that

 

used space

 

20% of the

 

falls below

 

block must

 

40%, new

 

remain open

 

rows can

 

for updates of

 

again be

 

existing rows.

 

inserted into

 

This cycle

 

this block.

 

continues . . .

In a newly allocated data block, the space available for inserts is the block size minus the sum of the block overhead and free space (PCTFREE). Updates to existing data can use any available space in the block. Therefore, updates can reduce the available space of a block to less than PCTFREE, the space reserved for updates but not accessible to inserts.

Information on Deprecated Features B-19

PCTFREE, PCTUSED, and Row Chaining

For each data and index segment, Oracle maintains one or more free listslists of data blocks that have been allocated for that segment’s extents and have free space greater than PCTFREE. These blocks are available for inserts. When you issue an INSERT statement, Oracle checks a free list of the table for the first available data block and uses it if possible. If the free space in that block is not large enough to accommodate the INSERT statement, and the block is at least PCTUSED, then Oracle takes the block off the free list. Multiple free lists for each segment can reduce contention for free lists when concurrent inserts take place.

After you issue a DELETE or UPDATE statement, Oracle processes the statement and checks to see if the space being used in the block is now less than PCTUSED. If it is, then the block goes to the beginning of the transaction free list, and it is the first of the available blocks to be used in that transaction. When the transaction commits, free space in the block becomes available for other transactions.

B-20 Oracle9i Database Concepts

Соседние файлы в папке Oracle selected docs