oracle体系结构(四)

时间:2022-09-05 09:05:29

Overview of Extents

An extentis a logical unit of database storage space allocation made up of a number of contiguousdata blocks. One or more extents in turn make up a segment. When the existingspace in a segment is completely used, Oracle allocates a new extent for the segment.

区是由许多连续的数据块组成的逻辑数据库存储分配空间的单位。一个或者更多的区组成一个段。当一个段中的已有空间完全使用后,oracle会为这个段分配一个新的区。

 

When Extents Are Allocated

When youcreate a table, Oracle allocates to the table’s data segment an initial extent ofa specified number of data blocks. Although no rows have been inserted yet, theOracle data blocks that correspond to the initial extent are reserved for thattable’s rows.

当用户创建一个表的时候,oracle会为这个表的数据段分配一个有规格数量数据块组成的初始区。尽管这个时候这个表中还没有插入数据,但是oracle已经为插入表的数据行预留了相当于初始区大小的数据块空间。

 

If thedata blocks of a segment’s initial extent become full and more space isrequired to hold new data, Oracle automatically allocates an incremental extentfor that segment. An incremental extent is a subsequent extent of the same orgreater size than the previously allocated extent in that segment.

如果一个段的初始区下的数据块被充满,并且又有新的数据需要更多的空间,oracle会自动为这个段分配一个自增长的区。自增长区是一个后来由oracle自动分配的区,段中的自增长区与之前已有的区大小一样,甚至更大。

 

Formaintenance purposes, the header block of each segment contains a directory of theextents in that segment.

鉴于易于维护的目的,每个段的首部中包含一个记录此段所有区的目录。

Note:This chapter applies to serial operations, in which one server process parsesand runs a SQL statement. Extents are allocated somewhat differently inparallel SQL statements, which entail multiple server processes.

注意:本章的内容适用于串行执行(serialoperation)的情况,即只有一个服务进程解析、执行 SQL 语句。对于并行执行(parallel)的 SQL 语句(即一个语句由多个服务进程执行),区(extent)的分配情况有所不同。

 

Determine theNumber and Size of Extents规划区的大小和数目

Storage parameters expressed in terms of extents define every segment. Storage parameters apply to all types of segments. They control how Oracle allocates free database space for a given segment. For example, you can determine how much space is initially reserved for a table’s data segment or you can limit the number of extents the table can allocate by specifying the storage parameters of a table in the STORAGE clause of the CREATE TABLE statement. If you do not specify atable’s storage parameters, then it uses the default storage parameters of thetablespace.

每个段定义了表达区信息的存储参数。存储参数适用于所有类型的段。这些参数控制oracle如何为一个已存在的段分配空闲的数据空间。例如,用户可以在CREATE TABLE 语句中使用STORAGE 子句设定存储参数,决定创建表时为其数据段分配多少初始空间,或限定一个表最多可以包含多少区。如果你没有指定一个表的存储参数,那么oracle就会使用该表所在表空间的默认存储参数。

 

You can have dictionary managedtablespaces, which rely on data dictionary tables to track space utilization,or locally managed tablespaces, which use bitmaps (instead of data dictionary tables) to track used and free space. Because of the better performance andeasier manage ability of locally managed tablespaces, the default for non-SYSTEMpermanent tablespaces is locally managed whenever the type of extent management is not explicitly specified.

用户既可以使用数据字典管理的表空间(dictionary managed tablespace)(依赖数据字典表监控空间的利用情况),也可以使用本地管理的表空间(locally managed tablespace)(使用位图(bitmap)来标记可用与已用空间)。由于本地管理的表空间性能较好且易于管理,当用户没有显式地设定数据扩展(extent)管理参数时,除了 SYSTEM 之外的所有永久表空间(permanent tablespace)默认使用本地管理方式。

 

Atablespace that manages its extents locally can have either uniform extent sizesor variable extent sizes that are determined automatically by the system. Whenyou create the tablespace, the UNIFORM or   AUTOALLOCATE(system-managed)clause specifies the type of allocation.

在一个本地管理的表空间中,其中所分配的区的容量既可以是用户设定的固定值,也可以是由系统自动决定的可变值。当你创建表空间的时候,UNIFORMAUTOALLOCATE(系统管理的)字句指定了分配的区的管理模式。

 

For uniform extents, you can specify an extent size or use the defaultsize, which is 1 MB. Ensure that each extent contains at least five databaseblocks, given the database block size. Temporary tablespaces that manage theirextents locally can only use this type of allocation.

For system-managed extents, Oracle determines the optimal size ofadditional extents, with a minimum extent size of 64 KB. If the tablespaces arecreated with 'segment space management auto’, and if the database block size is16K or higher, then Oracle manages segment size by creatingextents with a minimum size of 1M. This is the default for permanenttablespaces.

对于统一区管理,用户可以指定区的大小,或者使用默认的区大小,默认的区大小是1MB。考虑到数据库块的大小,统一区管理指定区大小的时候要确保每一个区包括至少5个数据库块。

对于系统管理区,由Oracle决定新增数据扩展的最佳容量,其最小容量为 64 KB。如果创建表空间时使用了“segment space management auto”子句,且数据块容量大于等于 16 KBOracle扩展一个段时所创建的区的最小容量为 1 MB。对于永久表空间(permanent tablespace)上述参数均为默认值。

 

The storage parameters INITIAL,NEXT, PCTINCREASE,andMINEXTENTS cannot be specified at the tablespace level for locally managed tablespaces. They can, however, be specified at the segment level. In thiscase, INITIAL, NEXT, PCTINCREASE, and MINEXTENTS are used together to computethe initial size of the segment. After the segment size is computed, internalalgorithms determine the size of each extent.

在本地管理的表空间(locally managed tablespace)中,INITIALNEXTPCTINCREASE,和 MINEXTENTS 这四个存储参数可以作用于段(segment),但不能作用于表空间。INITIALNEXTPCTINCREASE,和 MINEXTENTS 相结合可以用于计算段的初始容量。当段容量确定后,Oracle使用内部算法确定其中每个初始区的容量。