Friday, April 02, 2010

[Study] Oracle 9i Space Management Demystified (1)

[原文在此] Original file here

今天早上找到的好文章。版本老是老了點,不過有很多概念是一直延續的,個人認為這篇還有讀的價值。

開場白就說了database administrator花了他們大部分的時間在做space utilization, 而oracle 9i相當好心的提供了3個改革來改善DBA們的生命XD。
  • Automatic Undo Management
  • Locally Managed Tablespace
  • Auto Segment Space Management
因為我是在找tablespace fragmentation相關議題的時候看到這篇文章的,所以會先從Locally managed tablespace這塊讀起。

Locally Managed Tablespace
首先介紹名字的由來,Locally Managed Tablespace是針對extents管理的一個改革。傳統的tablespace management方法是利用data dictionary (tables) 來追蹤extents的使用狀況(所以稱為dictionary-managed tablespace),因為data dictionary屬於SYS, 是在不同的tablespace裡,所以整個資料庫內extents被分配或釋放時,都要集中在SYS tablespace裡記錄,還會有資源搶用(contention)的問題。
Dictionary Managed
Locally Managed
space managed bydata dictionary (SYS)bitmap (datafile header)
generate undo info.yesno
auto coalesce free spacenoyes

使用Locally managed tablespace還有分兩種決定extent size的方法: AUTO ALLOCATE跟UNIFORM EXTENT。
AUTO ALLOCATEUNIFORM EXTENT
size decisionby Oracle automaticallyDBA
decision factorcorresponding segment?: base on db utilization
initial extentsmaller (64K)? (default 1M)
when enough free space not availableauto allocates smaller extentsfail
which mode to use1. objects in tablespace vary drastivally in size
2. growth pattern is expected to be highly dynamic
only if all objects in the db are going to be of the same size and grow in a uniform manner

整體上看來,還是建議使用AUTO ALLOCATE模式即可。許多人可能認為使用UNIFORM EXTENT可以保證被釋放的extnets一定可以再被重新利用,因此也比較能減少fragment的現象。但其實不然,就像上面表格裡建議的,若是tablespace裡的物件經常性的建立還有刪除(像是暫時建了Table當作資料處理的中繼站),那麼使用uniform就相當浪費空間,因為不管表格大或小,他就是會佔去一個固定大小的extent。反過來看auto allocate模式下的extents,雖然大小各不相同,但是他們基本上還是follow一個基本的模式在增長,通常是initial extent的倍數,所以再被重新利用並不難。

造成fragmentation的現象的主因並非extents size不同,而是因為tablespace裡的objects follow不同的extent sizing policy,而導致被釋放的extent很難再被重新利用。所以要用auto還是uniform mode? 基本上還是視資料庫的使用情形決定。

整體上看來,locally managed tablespace有兩大優點:
  1. 效能較好: 因為少了data dictionary的搶用;還有他對space的管理方式,也是提升效能的關鍵之一(long running queries, add and drop objects)。
  2. 較少fragmentation: 如上述。
OK!!! 這就是locally managed tablespace的部分,是這三個主題裡篇幅最少的一個惹~ XD

Comments

0 Responses to "[Study] Oracle 9i Space Management Demystified (1)"

Post a Comment

Tags