oracle體系結構(三)

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).
對於手動管理模式的表空間來說,PCTFREE和PCTUSED這兩個空間管理參數使用戶能夠控制一個特定段的所有數據塊中對行進行插入操作和更新操作所需要使用的可用空間區。你可以在創建或者修改表、簇表(擁有自身獨立的數據段)的時候指定這兩個參數。你也可以在創建或者修改一個索引(擁有自己的索引段)的時候指定PCTFREE這個存儲參數。

The PCTFREEParameter   PCTFREE參數

The  PCTFREE parameter sets the minimum percentageof a data block to be reserved as free space for possible updates to rows thatalready exist in that block. For example, assume that you specify the followingparameter within a  CREATE   TABLE statement:

PCTFREE20

Thisstates that 20% of each data block in this table’s data segment be kept freeand available for possible updates to the existing rows already within eachblock. New rows can be added to the row data area, and correspondinginformation can be added to the variable portions of the overhead  area, until the row data and overhead total80% of the total block size.  Figure 2–3illustrates  PCTFREE :

PCTFREE 參數用來設置一個數據塊中最少要保留的可用空間區(按百分比計算的),這些可用空間區用於已存在在數據塊中的行數據在更新時可能發生的數據增長。例如,假如你在創建表語句中指定了下面的參數:

PCTFREE20

這個參數指定了在這個表的數據段的每個數據塊會保留20%的可用空間,以備每個數據塊中因行數據變更可能造成的數據增長。直到行數據和首部的空間佔用了整個數據塊空間的80%的之前,新的行數據可以添加到行數據區域,而與此匹配的信息會被添加到首部區域的可變部分。Figure 2–3說明了PCTFREE。

The PCTUSED Parameter    PCTUSED參數

The PCTUSED parameter sets the minimum percentage of a block that can be used for row dataplus overhead before new rows are added to the block. After a data block isfilled to the limit determined by PCTFREE, Oracle considers the blockunavailable for the insertion of new rows until thepercentage of that block falls beneath the parameter PCTUSED. Until this valueis achieved, Oracle uses the free space of the data block only for updates torows already contained in the data block. For example, assume that you specifythe following parameter in a CREATE  TABLE statement:

PCTUSED 40

In thiscase, a data block used for this table’s data segment is considered unavailablefor the insertion of any new rows until the amount of used space in the blockfalls to 39% or less (assuming that the block’s used space has previouslyreached PCTFREE). Figure 2–4  illustratesthis.

PCTUSED參數設置了新行數據沒有添加到數據塊前行數據和塊首部之和佔用的最小的數據塊空間的百分比。在數據塊被填滿達到PCTFREE設置的下限之後,oracle會在數據塊中的佔用量降到PCTUSED設置的值前認爲這個數據塊是無法插入新的數據行的。在佔用容量比例小於PCTUSED設置的值的時候,oracle只在更新數據塊中已存在的數據行的時候纔會使用此數據塊的可用空間區。例如,當用戶在創建表的語句中指定如下參數:

PCTUSED40

在這種情況下,在數據塊中已使用的空間的數據值下降到39%或者更少的情況,oracle認爲這個表的數據段中的這個數據塊是不能插入任何數據行的(假設此數據塊的可用空間曾經低於 PCTFREE 的限定)。Figure 2-4說明了PCTUSED。

How PCTFREE andPCTUSED Work Together  

PCTFREEand PCTUSED work together to optimize the use of space in the data blocks ofthe extents within a data segment. Figure 2–5 illustrates the interaction ofthese two parameters.

PCTFREE 和PCTUSED協同工作可以優化段下區中的數據空間。Figure 2–5說明了這兩個參數之間的相互作用。

In anewly allocated data block, the space available for inserts is the block sizeminus the sum of the block overhead and free space (PCTFREE). Updates toexisting data can use any available space in the block. Therefore, updates canreduce the available space of a block to less than PCTFREE, the space reservedfor updates but not accessible to inserts.

對已一個新創建的數據塊來說,可用於插入數據行的空間等於整個數據塊的空間減去數據塊首部與數據塊可用空間區(PCTFREE)之和。只要數據塊有可用的空間,那麼就可以對已存在的數據進行更新操作。更新可以減少一個塊的可用空間小於PCTFREE的控制,因此這些空間留給更新用的而不是留給插入操作。

 

For eachdata and index segment, Oracle maintains one or more free lists —lists of datablocks that have been allocated for that segment’s extents and have free space greaterthan 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 anduses it if possible. If the free space in that block is not large enough to accommodatethe INSERT statement, and the block is at least PCTUSED, then Oracle takes theblock off the free list. Multiple free lists for each segment can reduce contentionfor free lists when concurrent inserts take place.

在每個數據段(data segment)與索引段(index segment)中,Oracle管理着一個或多個可用塊列表(free list--其中列出了所有屬於此段的數據擴展(extent),且可用空間比例大於 PCTFREE 限定的數據塊。這些塊可以被插入(insert)操作使用。當用戶提交了 INSERT 語句後,Oracle從可用塊列表中選擇第一個有效的數據塊使用。如果此數據塊的可用空間不夠容納 INSERT 語句提交的數據,且此塊的佔用容量已經超過PCTUSED 的限定,Oracle就將其從可用塊列表中移出。一個段可以同時使用多個可用塊列表,以減少對一個表進行併發插入(concurrent insert)時產生的競爭。

 

After youissue a DELETE or UPDATE statement, Oracle processes the statement and checksto 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 isthe first of the available blocks to be used in that transaction. When thetransaction commits, free space in the block becomes available for othertransactions.

當用戶提交了 DELETEUPDATE 語句後,Oracle處理語句並檢查相關數據塊中的佔用空間比例是否小於 PCTUSED 的規定。如果滿足,那麼這個數據塊就被放入當前事務(transaction)正在使用的可用塊列表(free list)的頭部,如果當前事務還需要寫入數據,此塊將被首先使用。當事務提交後,此數據塊中的可用空間還可被其他事務使用。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章