extents分配策略及AUTOALLOCATE碎片问题

来源:互联网 发布:word2016 mac破解版 编辑:程序博客网 时间:2024/04/29 20:02
Starting with Oracle 9i, DBAs can now create locally managed tablespaces. 

A Locally Managed TBS manages its own list of free extents in a bitmap block placed inside the header of the first data file of the tablespace. Inside the bitmap block, each bit maps to a free block in the tablespace. 
When creating a locally managed tablespace, you can specify the extent allocation method to be used.

AUTOALLOCATE - means that the extent sizes are managed by Oracle. 

Oracle will choose the optimal next size for the extents starting with 64KB. As the segments grow and more extents are needed, Oracle will start allocating larger and larger sizes ranging from 1Mb to eventually 64Mb extents. This might help conserve space but will lead to fragmentation. This is usually recommended for small tables or in low managed systems.

UNIFORM - specifies that the extent allocation in the tablespace is in a fixed uniform size. The extent size can be specified in M or K. The default size for UNIFORM extent allocation is 1M. Using uniform extents usually minimizes fragmentation and leads to better overall performance.

     本文讲的是从9i之后引进的本地表空间管理的extents分配策略。 Storage(tablespace) :  extent有自动扩展(AUTOALLOCATE),有uniform. size(同样大小)。

      Autoallocate模式:

      AUTOALLOCATE时的extent扩展规则是
        
       Oracle9i 下:
       0-15    extents 每个大小是64K 合计大小 1M
       16-79  extents 每个大小是1M 合计大小 63M --以上两项大小合计 64M
       80-199 extents 每个大小是8M 合计大小 960M --以上三项大小合计 1024M=1G
       200-?  extents 每个大小是64M

       Oracle10g下有变化 : 
       extent0 ~127= 8M   总大小  128×8M=1G
       extent 128=64M   当segment的大小大于1G时,oracle开始分配64M的extents。

       注:当选择Autoallocate模式时,容易造成碎片。比如:

        下面我已Oracle9i的本地管理表空间设置为AUTOALLOCATE 为前提,来说明“fragmentation ” 或者“hole”产生的原因
   假设现在我们现在将在表空间上创建10个表
   t1,t2,t3,t4,t5,t6,t7,t8,t9.t0
   那么最初的extent的都是64k,总大小为640K
   假设现在有10个extent依次排开(注意这些extent是64k,即每一个表占据一个extent)
   现在我们扩展其中5个表  t1,t2,t3,t4,t5
   那么继续假设扩展的总大小为15M
   那么现在有5个extent依次排开(注意这些extent是1M,即每个被扩展的表占据了一个extent)
   
   现在我们删除(即drop)没别扩展的两个:t7,t9
   恰好t7,t9又不连续,那么就剩下了两个独立分布而不连续的64k的extent
   
   如果之后我们不建立新的table
   而且其他表只会保持一种增长的状态(即这时需要的extent只会大于64k)
   那么这些独立分散的extent再也不能被使用到,所以就成了hole,成为了fragmentation。drop/truncate后,由于空余空间不连续,

   所以可能会导致剩余空间的总      和是足够扩展的,但是可能出现任意连续的剩余空间总和却不足以扩展一个extend的现象。

    而如果是uniformsize大小的extent,即使extent是单个的不连续,因为表空间扩展时,只会需要固定大小即uniformsize
     的extent即可,所以独立的extent不再是孤魂野鬼,而是星星之火,可以燎原了。
 
     因此,系统管理区大小适用于段比较多、而且段一般不会很大。
     而统一区大小非常适合很大的段,而且,统一区大小的性能比系统管理区大小要略好一点。

 

0 0
原创粉丝点击