数据块
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.