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字節。

 

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