資料區塊
In an Oracle database, the block is the smallest unit of data file I/O and the smallest unit of space that can be allocated. An Oracle block consists of one or morecontiguous operating system blocks.
標準塊大小
- 在建立資料庫時使用DB_BLOCK_SIZE參數設定;除非重新建立該資料庫,否則無法更改
- 用於SYSTEM和TEMPORARY資料表空間
- DB_CACHE_SIZE指定標準塊大小的DEFAULT緩衝區快取大小:
- 最小大小= 一個粒組(4 MB 或16 MB)
- 預設值= 48 MB
DB_BLOCK_SIZE初始化參數用於指定資料庫的標準塊大小。該塊大小用於SYSTEM資料表空間,以及任何暫存資料表空間。除非進行指定,否則,標準塊大小還用作資料表空間的預設塊大小。Oracle 最多支援四種附加的非標準塊大小。
DB_CACHE_SIZE參數用於指定標準塊大小緩衝區的快取大小,其中的標準塊大小是由DB_BLOCK_SIZE指定的。
註:粒組是一個連續虛擬記憶體分配單位。粒組的大小取決於估算的SGA 的總大小,這個總大小是根據SGA_MAX_SIZE的參數值計算的:如果估算的SGA的大小< 128 MB,則為4 MB;否則為16 MB。
非標準塊大小
- DB_2K_CACHE_SIZE用於2 KB 塊
- DB_4K_CACHE_SIZE用於4 KB 塊
- DB_8K_CACHE_SIZE用於8 KB 塊
- DB_16K_CACHE_SIZE用於16 KB 塊
- DB_32K_CACHE_SIZE用於32 KB 塊
- 如果nK是標準塊大小,則不允許使用DB_nK_CACHE_SIZE
- 每個快取的最小大小:一個粒組
資料庫緩衝區快取初始化參數決定了SGA 資料庫緩衝區快取組件的大小。可以使用這些參數為資料庫使用的各種塊大小指定快取大小。如果要在資料庫中使用多種塊大小,則必須設定DB_CACHE_SIZE和至少一個DB_nK_CACHE_SIZE參數。每個參數為相應的塊大小指定了緩衝區快取大小。DB_nK_CACHE_SIZE參數的預設值為零。如果存在塊大小為n KB 的聯機資料表空間,則不要將此參數設定為零。
平台特定的塊大小具有一些限制。例如,如果平台上的最大塊大小小於32 KB,則不能設定DB_32K_CACHE_SIZE。此外,如果最小塊大小大於2 KB,則不能設定DB_2K_CACHE_SIZE。
註:這些參數不能用於調整標準塊大小的快取大小。例如,如果DB_BLOCK_SIZE的值為2 KB,則設定DB_2K_CACHE_SIZE是非法的。標準塊大小的快取大小始終由DB_CACHE_SIZE的值確定。
建立非標準塊大小的資料表空間
1 CREATE TABLESPACE tbs_1 DATAFILE 'tbs_1.dbf' SIZE 10M BLOCKSIZE 4K;
--要指定該子句,必須設定DB_CACHE_SIZE和至少一個DB_nK_CACHE_SIZE參數,在該子句中指定的整數必須與某個DB_nK_CACHE_SIZE參數的設定值對應
Small Block Size:
- Small blocks reduce block contention, because there are fewer rows per block.
- Small blocks are good for small rows.
- Small blocks are good for random access. If it is unlikely that a block will be reused after it is read into memory, then a smaller block size makes more efficient use of the buffer cache. This is especially important when memory resources are scarce, because the
size of the database buffer cache is limited.
- Small blocks have relatively large overhead.
- Depending on the size of the row you may end up storing only a small number of rows per block,. This can cause additional I/Os.
- Small blocks can cause moreindex blocks to be read.
- For random access to a large object, as in an OLTP environment, small blocks are favored
Large Block Size:
- There is less overhead and thus more room to store useful data.
- Large blocks are good for sequential reads.
- Large blocks are good for very large rows.
- Larger blocks improve the performance of index reads. The larger blocks can hold more index entries in each block, which reduces the number of levels in large indexes. Fewer index levels mean fewer I/Os when traversing the index branches.
- A large block size is not good for index blocks used in an OLTP environment, because they increase block contention on the index leaf blocks.
- Space in the buffer cache is wasted if you randomly access small rows and have a large block size. For example, with an 8 KB block size and a 50 byte row size, you waste 7,950 bytes in the buffer cache when doing a random access.
- Sequential access to large amounts of data, as in a DSS environment, prefers large blocks.