oracle ASSM和MSSM

一. 官网说明

Logical Storage Structures

http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/logical.htm#CNCPT7668

 

其中有关ASSM 的内容如下:

 

Logical Space Management

Oracle Database must use logical spacemanagement to track and allocate the extents in atablespace. When a database object requires an extent, the databasemust have a method of finding and providing it. Similarly, when anobject no longer requires an extent, the database must have amethod of making the free extent available.

Oracle Database managesspace within a tablespace based on the type that you create. Youcan create either of the following types of tablespaces:

·        Locally managed tablespaces (default)

The database uses bitmaps in the tablespaces themselves tomanage extents. Thus, locally managed tablespaces have a part ofthe tablespace set aside for a bitmap. Within a tablespace, thedatabase can manage segments with automatic segment spacemanagement (ASSM) or manual segment spacemanagement (MSSM).

·        Dictionary-managed tablespaces

The database uses the data dictionary to manage extents (see "Overview of the Data Dictionary").

Figure 12-3 shows the alternatives for logical space managementin a tablespace.

Figure 12-3 Logical SpaceManagement


Descriptionof "Figure 12-3 Logical Space Management"

Locally ManagedTablespaces

A locallymanaged tablespace maintains a bitmap in the data file header totrack free and used space in the data file body. Each bitcorresponds to a group of blocks. When space is allocated or freed,Oracle Database changes the bitmap values to reflect the new statusof the blocks.

The following graphic is a conceptual representation ofbitmap-managed storage. A 1 in the header refers toused space, whereas a 0 refers to free space.

A locally managed tablespace has the following advantages:

·        Avoids using the data dictionary to manage extents

Recursive operations can occur in dictionary-managed tablespacesif consuming or releasing space in an extent results in anotheroperation that consumes or releases space in a data dictionarytable or undo segment.

·        Tracks adjacent free space automatically

In this way, the database eliminates the need to coalesce freeextents.

·        Determines the size of locally managed extents automatically

Alternatively, all extents can have the same size in a locallymanaged tablespace and override object storage options.

Note:

Oracle strongly recommends the use of locally managedtablespaces with Automatic Segment Space Management.

Segment space management is an attributeinherited from the tablespace that contains the segment. Within alocally managed tablespace, the database can manage segmentsautomatically or manually. For example, segments in tablespaceusers can be managed automatically while segments intablespace tools are managed manually.

Automatic Segment Space Management

The ASSM method uses bitmaps to manage space. Bitmaps providethe following advantages:

·        Simplified administration

ASSM avoids the need to manually determine correct settings formany storage parameters. Only one crucial SQL parameter controlsspace allocation: PCTFREE. This parameter specifiesthe percentage of space to be reserved in a block for futureupdates (see "Percentage of Free Space in Data Blocks").

ASSM 管理,只需要一个参数:PCTFREE

·        Increased concurrency

Multiple transactions can search separate lists of free data blocks,thereby reducing contention and waits. For many standard workloads,application performance with ASSM is better than the performance ofa well-tuned application that uses MSSM.

·        Dynamic affinity of space to instances in an Oracle RealApplication Clusters (Oracle RAC) environment

ASSM is more efficient and is the default for permanent, locallymanaged tablespaces.

Note:

This chapter assumes the use of ASSM in all of its discussionsof logical storage space.

 

Manual Segment Space Management

The legacy MSSM method uses a linked list called a freelist to manage free space in the segment. For a databaseobject that has free space, a free list keeps track of blocks underthe high water mark (HWM), which is the dividing line betweensegment space that is used and not yet used. As blocks are used,the database puts blocks on or removes blocks from the free list asneeded.

In addition to PCTFREE, MSSM requires you tocontrol space allocation with SQL parameters such asPCTUSED, FREELISTS, and FREELISTGROUPS. PCTUSED sets the percentage of freespace that must exist in a currently used block for the database toput it on the free list. For example, if you setPCTUSED to 40 in a CREATETABLE statement, then you cannot insert rows into a block inthe segment until less than 40% of the block space is used.

As an illustration, suppose you insert a row into a table. Thedatabase checks a free list of the table for the first availableblock. If the row cannot fit in the block, and if the used space inthe block is greater than or equal to PCTUSED, thenthe database takes the block off the list and searches for anotherblock. If you delete rows from the block, then the database checkswhether used space in the block is now less thanPCTUSED. If so, then the database places the block atthe beginning of the free list.

An object may have multiple free lists. In this way, multiplesessions performing DML on a table can use different lists, whichcan reduce contention. Each database session uses only one freelist for the duration of its session.

As shown in Figure 12-4, you can also create an object with one or morefree list groups, which are collections of freelists. Each group has a master free list thatmanages the individual process free lists in thegroup. Space overhead for free lists, especially for free listgroups, can be significant.

Figure 12-4 Free ListGroups


Descriptionof "Figure 12-4 Free List Groups"

Managing segment space manually can be complex. You must adjustPCTFREE and PCTUSED to reduce rowmigration (see "Chained and Migrated Rows") and avoid wasting space. Forexample, if every used block in a segment is half full, and ifPCTUSED is 40, then the database does not permitinserts into any of these blocks. Because of the difficulty offine-tuning space allocation parameters, Oracle strongly recommendsASSM. In ASSM, PCTFREE determines whether a new rowcan be inserted into a block, but it does not use free lists andignores PCTUSED.

-- ASSM 会忽略PCTUSED 参数

Dictionary-Managed Tablespaces

Adictionary-managed tablespace uses the data dictionary to manageits extents. Oracle Database updates tables in the data dictionarywhenever an extent is allocated or freed for reuse. For example,when a table needs an extent, the database queries the datadictionary tables, and searches for free extents. If the databasefinds space, then it modifies one data dictionary table and insertsa row into another. In this way, the database manages space bymodifying and moving data.

The SQL that the database executes in the background to obtainspace for database objects is recursive SQL.Frequent use of recursive SQL can have a negative impact onperformance because updates to the data dictionary must beserialized. Locally managed tablespaces, which are the default,avoid this performance problem.

 

二.  ASSM 说明

 

           在Orale9i以前,表的剩余空间的管理与分配都是由链接列表freelist来完成的,因为freelist存在串行的问题因此容易引起往往容易引起段头的争用与空间的浪费(其实这一点并不明显),最主要的还是因为需要DBA花费大量的精力去管理这些争用并监控表的空间利用。  

           自动段空间管理(ASSM),它首次出现在Oracle920里。有了ASSM,链接列表freelist被位图所取代,它是一个二进制的数组,能够迅速有效地管理存储扩展和剩余区块(freeblock),因此能够改善分段存储本质,ASSM表空间上创建的段还有另外一个称呼叫Bitmap ManagedSegments(BMB 段)。  


让我们看看位图freelist是如何实现的。从使用区段空间管理自动参数创建tablespace开始:  
create tablespace demo  
datafile '/ora01/oem/demo01.dbf'  
size 5m  
EXTENT MANAGEMENT LOCAL -- Turn onLMT  
SEGMENT SPACE MANAGEMENT AUTO -- Turn onASSM;  

一旦你定义好了tablespace,那么表和索引就能够使用各种方法很容易地被移动到新的tablespace里,带有ASSM的本地管理tablespace会略掉任何为PCTUSED、NEXT和FREELISTS所指定的值。  


           当表格或者索引被分配到这个tablespace以后,用于独立对象的PCTUSED的值会被忽略,而Oracle9i会使用位图数组来自动地管理tablespace里表格和索引的freelist。对于在LMT的tablespace内部创建的表格和索引而言,这个NEXT扩展子句是过时的,因为由本地管理的tablespace会管理它们。但是,INITIAL参数仍然是需要的,因为Oracle不可能提前知道初始表格加载的大小。对于ASSM而言,INITIAL最小的值是三个块。  


           新的管理机制用位图来跟踪或管理每个分配到对象的块,每个块有多少剩余空间根据位图的状态来确定,如>75%,50%-75%,25%-50%和<25%,也就是说位图其实采用了四个状态位来代替以前的pctused,什么时候该利用该数据块则由设定的pctfree来确定。  


          

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值