Oracle有效地使用块(1)

数据块  

  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缓冲区高速缓存大小:
  1. 最小大小= 一个粒组(4 MB 或16 MB)
  2. 缺省值= 48 MB

  DB_BLOCK_SIZE初始化参数用于指定数据库的标准块大小。该块大小用于SYSTEM表空间,以及任何临时表空间。除非进行指定,否则,标准块大小还用作表空间的缺省块大小。Oracle 最多支持四种附加的非标准块大小。

  DB_CACHE_SIZE参数用于指定标准块大小缓冲区的高速缓存大小,其中的标准块大小是由DB_BLOCK_SIZE指定的。

注:粒组是一个连续虚拟内存分配单位。粒组的大小取决于估算的SGA 的总大小,这个总大小是根据SGA_MAX_SIZE的参数值计算的:如果估算的SGA的大小< 128 MB,则为4 MB;否则为16 MB。

非标准块大小

  • 使用以下动态参数配置附加高速缓存
  1. DB_2K_CACHE_SIZE用于2 KB 块
  2. DB_4K_CACHE_SIZE用于4 KB 块
  3. DB_8K_CACHE_SIZE用于8 KB 块
  4. DB_16K_CACHE_SIZE用于16 KB 块
  5. 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:

  • Advantages
  1. Small blocks reduce block contention, because there are fewer rows per block.
  2. Small blocks are good for small rows.
  3. 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.

  • Disadvantages
  1. Small blocks have relatively large overhead.
  2. 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.
  3. Small blocks can cause moreindex blocks to be read.
  • Performance:
  1. For random access to a large object, as in an OLTP environment, small blocks are favored

Large Block Size:

  • Advantages
  1. There is less overhead and thus more room to store useful data.
  2. Large blocks are good for sequential reads.
  3. Large blocks are good for very large rows.
  4. 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.
  • Disadvantages
  1. 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. 
  2. 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. 
  • Performance
  1. Sequential access to large amounts of data, as in a DSS environment, prefers large blocks.

 

 

 

 

 

 

posted @ 2013-02-28 09:58  PoleStar  阅读(318)  评论(0编辑  收藏  举报