oracle体系结构(一)

Introduction to Data Bloc ks, Extents, and Segments

Oracle allocates logical database space for all data in a database. The units of database space allocation are data blocks, extents, and segments. Figure 2-1  shows the relationships among these data structures:

Oracle为数据库中的所有数据分配负荷逻辑的数据库空间。数据库空间是由数据块、区和段组成。Figure 2–1展示这三个数据结构间的关系:

At the finest level of granularity, Oracle stores data in data blocks (also called logical blocks,  Oracle blocks , or pages ). One data block corresponds to a specific number of bytes of physical database space on disk.

从上面的Figure 2–1可以看出,oracle存储数据的最小级别是数据块(也可称作是逻辑块、oracle块或者页)。一个数据块对应于一个特定数量字节的磁盘上的物理数据库空间。

 

The next level of logical database space is an extent . An extent is a specific numberof contiguous data blocks allocated for storing a specific type of information.

区是第二层的逻辑数据库空间单位。区是由一个特定数量的连续的数据块组成,这些块是被分配用来存储一个特定类型的信息。

 

The level of logical database storage greater than an extent is called a segment .A segment is a set of extents, each of which has been allocated for a specific data structure and all of which are stored in the same tablespace.For example, each table’s data is stored in its own data segment, while each index’s data is stored in its own index segment . If the table or index is partitioned, each partition is stored in its own segment.

比区更大的逻辑数据库存储单位是段。段是由一组区组成的,这些区每个都被分配了一个特定的数据结构并且都被存储在同一个表空间中。例如,每个表的数据被存储在它自己所有的数据段中,而每个索引的数据被存储在它自己的索引段中。如果这个表或者索引被分区,那么每个分区会被存储在它自己的拥有的段中。

 

Oracle allocates space for segments in units of one extent. When the existing extents of a segment are full, Oracle allocates another extent for that segment.Because extents are allocated as needed, the extents of a  segment may or may not be contiguous on disk.

Oracle以区为单位为段分配空间。当一个段中存在的区被存满的时候,oracle会为这个段分配另外一个区。由于段中区的分配是按需进行的,所以段中的区在磁盘上可能不是连续的。

 

A segment and all its extents are stored in one tablespace. Within a tablespace, asegment can include extents from more than one file; that is, the segment canspan datafiles. However, each extent can contain data from only one datafile.

一个段包括它所有的区都被存储在一个表空间中。在一个表空间,一个段可以包括一个或者更多文件中的区,即段可以跨数据文件来完成。

 

Although you can allocate additional extents, the blocks themselves are allocated separately. If you allocate an extent to a specific instance, the blocks are immediately allocated to the free list. However,  if the extent is not allocated to a specific instance, then the blocks themselves are allocated only when the high water mark moves. The high water mark is the boundary between used and unused space in a segment.

虽然你可以分配额外的区,但是块自身的分配是分开的。如果你为一个特定的实例分配了一个区,那么这个扩展块会立刻分配给instance中的free list。但是如果这个扩展块没有分配给一个指定的实例,那么只有当这个对象的水平线变化的时候,才会分配。高水位是已使用的段与没使用的段之间的分界线。

 

Overview of Data Blocks 数据块概述

Oracle manages the storage space in the datafiles of a database in units called datablocks. A data block is the smallest unit of data used by a database. Incontrast, at the physical, operating system level, all data is stored in bytes.Each operating system has a block size . Oracle requests data in multiples of Oracle data blocks, not operating system blocks.

Oracle是以数据块为单位管理数据库中数据文件存储空间的。数据块是构成数据库的最小数据单位。而与此不同的是,操作系统层次上,作为物理存储的数据是以byte为单位的。每个操作系统都有其自身的块大小。但是oracle访问的数据大小都是oracle数据块的整数倍,而与操作系统的块无关。

 

The standard block size is specified by the  DB_BLOCK_SIZE  initialization parameter. In addition, you can specify of up to five nonstandard block sizes. The data block sizes should be a multiple of the operating system’s block size within the maximum limit to avoidunnecessary I/O. Oracle data blocks are the smallest units of storage that Oracle can use or allocate.

标准块大小是通过初始化参数DB_BLOCK_SIZE特别指定的。此外,你还可以指定多达五个非标准块大小。数据块大小应该是一个多个操作系统的块大小以最大限度的避免不必要的I / Ooracle数据块是oracle可以使用和分配的最小的存储单位。

Data Block Format

The Oracle data block format is similar regardless of whether the data block contains table, index, or clustered data. Figure 2–2 illustrates the format of a data block.

不论数据块中存放的是表、索引或者是簇表,Oracle数据块的格式都是类似的。Figure 2–2说明了一个数据块的格式:

Header(Common and Variable)首部(公共部分和常量)

The header contains general block information, such as the block address and the type of segment (for example, data or index).

块首部包涵了一般的块信息,这些信息包涵诸如块地址以及段的类型(比如,数据或者索引)等。

Table Directory 表目录

This portion of the data block contains information about the table having rows in this block.

数据块的这部分包涵了关于数据块中拥有行的表的信息。

Row Directory 行目录

This portion of the data block contains information about the actual rows in the block (including addresses for each row piece in the row data area).

这部分的数据块包含了有关实际的行的信息(包括行数据区域每个行片段的地址)。

Overhead 块开销

The data block header, table directory, and row directory are referred to collectively as overhead. Some block overhead is fixed in size; the total block overhead size is variable. On average, the fixed and variable portions of data block overhead total 84 to 107 bytes.

数据块的首部、表目录和行目录统称为块开销。有些块开销大小是固定的,但是总的块开销的大小是可变的。平均来书,固定和可变部分的数据块开销合总84107字节。

 

After the space has been allocated in the row directory of a data block’s overhead, this space is not reclaimed when the row is deleted. Therefore, a block that is currently empty but had up to 50 rows at one time continues to have 100 bytes allocated in the header for the row directory. Oracle reuses this space only when new rows are inserted in the block.

一旦一个数据块的开销中的行目录已经被分配了空间,那么这个空间不会在这行记录删除的时候被回收利用。举例来说,当一个曾经包含50条记录的数据块被清空后,其块头(header)的行目录区仍然占用100字节(byte)的空间。只有在数据块中插入(insert)新数据的时候,行目录空间才会被重新利用Row Data 行数据

This portion of the data block contains table or index data. Rows can span blocks.

数据块的这部分包括了表和索引的数据。一条数据行是可以跨多个数据块的。

注:这就出现了“行链接(Row Chaining)及行迁移(Row Migrating)

Free Space 可用空间区

Free space is allocated for insertion of new rows and for updates to rows that require additional space (for example, when a trai ling null is updated to a nonnull value).

在插入新数据行,或在更新数据行需要更多空间时(例如,原来某行最后一个字段为空(trailing null),现在要更新为非空值),将使用可用空间区(free space)中的空间。

In data blocks allocated for the data segment of a table or cluster, or for the index segment of an index, free space can also hold transaction entries. A transaction entry is required in a block for each INSERT ,  UPDATE ,  DELETE , and SELECT ... FOR UPDATE statement accessing one or more rows in the block.The space required for transaction entries is operating system dependent;however, transaction entries in most operating systems require approximately 23bytes.

如果一个数据块被分配给一个表或者簇表的数据段,或者被分配给一个索引的索引段,那么可用空间区还可能存储事务条目。当一条或更多的行在数据块中的行被INSERT , UPDATE ,  DELETE , and  SELECT ... FOR UPDATE语句访问的时候,数据块中存在事务条目就是必须的。而事务条目需要的空间则是需要依操作系统而定。尽管如此,在大多数操作系统中,事务条目空间的需求大约23字节。

 

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