`

Oracle 自动段空间管理(ASSM:auto segment space management)

 
阅读更多

. 官网说明

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 space management to track and allocate the extents in a tablespace. When a database object requires an extent, the database must have a method of finding and providing it. Similarly, when an object no longer requires an extent, the database must have a method of making the free extent available.

Oracle Database manages space within a tablespace based on the type that you create. You can create either of the following types of tablespaces:

·Locally managed tablespaces (default)

The database uses bitmaps in the tablespaces themselves to manage extents. Thus, locally managed tablespaces have a part of the tablespace set aside for a bitmap. Within a tablespace, the database can manage segments with automatic segment space management (ASSM)or manual segment space management (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 management in a tablespace.

Figure 12-3 Logical Space Management


Description of "Figure 12-3 Logical Space Management"

<!-- class="figure" -->Locally Managed Tablespaces

A locally managed tablespace maintains a bitmap in the data file header to track free and used space in the data file body. Each bit corresponds to a group of blocks. When space is allocated or freed, Oracle Database changes the bitmap values to reflect the new status of the blocks.

The following graphic is a conceptual representation of bitmap-managed storage. A 1 in the header refers to used 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 tablespaces if consuming or releasing space in an extent results in another operation that consumes or releases space in a data dictionary table or undo segment.

·Tracks adjacent free space automatically

In this way, the database eliminates the need to coalesce free extents.

·Determines the size of locally managed extents automatically

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

Note:

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

Segment space management is an attribute inherited from the tablespace that contains the segment. Within a locally managed tablespace, the database can manage segments automatically or manually. For example, segments in tablespace users can be managed automatically while segments in tablespace tools are managed manually.

<!-- infolevel="all" infotype="General" -->Automatic Segment Space Management

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

·Simplified administration

ASSM avoids the need to manually determine correct settings for many storage parameters. Only one crucial SQL parameter controls space allocation: PCTFREE. This parameter specifies the percentage of space to be reserved in a block for future updates (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 of a well-tuned application that uses MSSM.

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

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

Note:

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

 

<!-- class="sect4" --><!-- infolevel="all" infotype="General" -->Manual Segment Space Management

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

In addition to PCTFREE, MSSM requires you to control space allocation with SQL parameters such as PCTUSED, FREELISTS, and FREELIST GROUPS. PCTUSED sets the percentage of free space that must exist in a currently used block for the database to put it on the free list. For example, if you set PCTUSED to 40 in a CREATE TABLE statement, then you cannot insert rows into a block in the segment until less than 40% of the block space is used.

As an illustration, suppose you insert a row into a table. The database checks a free list of the table for the first available block. If the row cannot fit in the block, and if the used space in the block is greater than or equal to PCTUSED, then the database takes the block off the list and searches for another block. If you delete rows from the block, then the database checks whether used space in the block is now less than PCTUSED. If so, then the database places the block at the beginning of the free list.

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

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

Figure 12-4 Free List Groups


Description of "Figure 12-4 Free List Groups"

<!-- class="figure" -->Managing segment space manually can be complex. You must adjust PCTFREE and PCTUSED to reduce row migration (see "Chained and Migrated Rows") and avoid wasting space. For example, if every used block in a segment is half full, and if PCTUSED is 40, then the database does not permit inserts into any of these blocks. Because of the difficulty of fine-tuning space allocation parameters, Oracle strongly recommends ASSM. In ASSM, PCTFREE determines whether a new row can be inserted into a block, but it does not use free lists and ignores PCTUSED.

-- ASSM 会忽略PCTUSED 参数

Dictionary-Managed Tablespaces

A dictionary-managed tablespace uses the data dictionary to manage its extents. Oracle Database updates tables in the data dictionary whenever an extent is allocated or freed for reuse. For example, when a table needs an extent, the database queries the data dictionary tables, and searches for free extents. If the database finds space, then it modifies one data dictionary table and inserts a row into another. In this way, the database manages space by modifying and moving data.

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

 

 

. ASSM 说明

 

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

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


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

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


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


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


使用ASSM的一个巨大优势是,位图freelist肯定能够减轻缓冲区忙等待buffer busy wait)的负担,这个问题在Oracle9i以前的版本里曾是一个严重的问题


在没有多个freelist的时候,每个Oracle表格和索引在表格的头部都曾有一个数据块,用来管理对象所使用的剩余区块,并为任何SQL插入声明所创建的新数据行提供数据块。当数据缓冲内的数据块由于被另一个DML事务处理锁定而无法使用的时候,缓冲区忙等待就会发生。当你需要将多个任务插入到同一个表格里的时候,这些任务就被强制等待,而同时Oracle会在同时分派剩余的区块,一次一个。


有了ASSM之后,Oracle宣称显著地提高了DML并发操作的性能因为(同一个)位图的不同部分可以被同时使用,这样就消除了寻找剩余空间的串行化。根据Oracle的测试结果,使用位图freelist会消除所有分段头部(对资源)的争夺,还能获得超快的并发插入操作


尽管ASSM显示出了令人激动的特性并能够简化Oracle DBA的工作,但是Oracle9i的位图分段管理还是有一些局限性的:
1.
一旦DBA被分配之后,它就无法控制tablespace内部的独立表格和索引的存储行为。

2.
大型对象不能够使用ASSM,而且必须为包含有LOB数据类型的表格创建分离的tablespace

3.
你不能够使用ASSM创建临时的tablespace。这是由排序时临时分段的短暂特性所决定的。

4.
只有本地管理的tablespace才能够使用位图分段管理。

使用超高容量的DML(例如INSERTUPDATEDELETE等)的时候可能会出现性能上的问题。



. 相关测试:

1、我们先创建一个本地管理的表空间,采用段自动管理方式
/* Formatted on 2009-12-7 19:17:33 (QP5 v5.115.810.9015) */

CREATETABLESPACE demo

DATAFILE'D:/demo01.dbf'

SIZE50M

EXTENTMANAGEMENTLOCAL--一定是本地管理

SEGMENTSPACEMANAGEMENTAUTO;--ASSM管理的标志

2、创建同样一个表
/* Formatted on 2009-12-7 19:18:00 (QP5 v5.115.810.9015) */

CREATETABLE demotab (x NUMBER)

TABLESPACE demo

STORAGE(INITIAL1000K);

 


我们指定初试区间大小是1000K

/* Formatted on 2009-12-7 19:18:37 (QP5 v5.115.810.9015) */

SELECTt.table_name,

t.initial_extent,

t.next_extent,

t.pct_free,

t.pct_used

FROMuser_tables t

WHEREt.table_name ='DEMOTAB';

 


TABLE_NAME INITIAL_EXTENT NEXT_EXTENT PCT_FREE PCT_USED
----------------------- -------------- ------------------------------- -------------------
DEMOTAB 1024000 10

可以看到,NEXT_EXTENTPCT_USED都为空。


3、执行该过程,检查表的初始状态

execshow_space('demotab','auto','T','Y'); --show_space() 代码见附件
Total Blocks............................128

Total Bytes.............................1048576

Unused Blocks...........................125

Unused Bytes............................1024000

Last Used Ext FileId....................7

Last Used Ext BlockId...................9

Last Used Block.........................3

*************************************************

The segment is analyzed

0% -- 25% free space blocks.............0

0% -- 25% free space bytes..............0

25% -- 50% free space blocks............0

25% -- 50% free space bytes.............0

50% -- 75% free space blocks............0

50% -- 75% free space bytes.............0

75% -- 100% free space blocks...........0

75% -- 100% free space bytes............0

Unused Blocks...........................0

Unused Bytes............................0

Total Blocks............................0

Total bytes.............................0


从这里我们能看到一些该表的特性,其中最引人注意的就是表头了,占用了三个块的大小(128-125
另外一个注意的地方就是该表从第9个块开始,文件头占用了64K的空间等于8个块。

我们从dba_extent中也能看到这样的信息,是从第9个块开始的。

/* Formatted on 2009-12-7 19:24:23 (QP5 v5.115.810.9015) */

SELECTt.segment_name,t.extent_id,t.block_id

FROMdba_extents t

WHEREt.segment_name ='DEMOTAB';

 

SEGMENT_NAMEEXTENT_IDBLOCK_ID

-----------------------------------

DEMOTAB09

DEMOTAB117

DEMOTAB225

DEMOTAB333

DEMOTAB441

DEMOTAB549

DEMOTAB657

DEMOTAB765

DEMOTAB873

DEMOTAB981

DEMOTAB1089

DEMOTAB1197

DEMOTAB12105

DEMOTAB13113

DEMOTAB14121

DEMOTAB15129

从这里可以看到,第一个区间的开始块是9

4、我直接开始分析第91011个块(段头)


SQL> alter system dump datafile 7 block 9;
System altered
SQL> alter system dump datafile 7 block 10;
System altered
SQL> alter system dump datafile 7 block 11;
System altered

进入Udump 查看刚才生成的trace 文件

*** 2009-12-07 19:30:16.406

*** SERVICE NAME:(DBA.ANQINGREN.ORG) 2009-12-07 19:30:16.390

*** SESSION ID:(123.758) 2009-12-07 19:30:16.390

Start dump data blocks tsn: 8 file#: 7 minblk 9 maxblk 9

buffer tsn: 8 rdba: 0x01c00009 (7/9)

scn: 0x0000.001a0da0 seq: 0x01 flg: 0x04 tail: 0x0da02001

frmt: 0x02 chkval: 0x44e6 type: 0x20=FIRST LEVEL BITMAP BLOCK

Hex dump of block: st=0, typ_found=1

Dump of memory from 0x085C8400 to 0x085CA400

85C8400 0000A220 01C00009 001A0DA0 04010000[ ...............]

85C8410 000044E6 00000000 00000000 00000000[.D..............]

85C8420 00000000 00000000 00000000 00000000[................]

Repeat 1 times

85C8440 00000000 00000000 00000000 00000004[................]

85C8450 FFFFFFFF 0000000D 00000003 00000010[................]

85C8460 00010002 00000000 00000000 00000000[................]

85C8470 00000000 00000003 00000000 00000000[................]

85C8480 00000000 00000000 00000000 00000000[................]

85C8490 01C0000A 00000000 00000000 00000003[................]

85C84A0 00000008 01C0000C 00000000 00000000[................]

85C84B0 00000000 00000000 00000000 00000001[................]

85C84C0 0000D302 00000000 00000000 01C00009[................]

85C84D0 00000008 00000000 01C00011 00000008[................]

85C84E0 00000008 00000000 00000000 00000000[................]

85C84F0 00000000 00000000 00000000 00000000[................]

Repeat 8 times

85C8580 00000000 00000000 00000000 00001011[................]

85C8590 00000000 00000000 00000000 00000000[................]

Repeat 485 times

85CA3F0 00000000 00000000 00000000 0DA02001[............. ..]

Dump of First Level Bitmap Block

--------------------------------

nbits : 4 nranges: 2parent dba:0x01c0000apoffset: 0

unformatted: 13total: 16first useful block: 3

owning instance : 1

instance ownership changed at

Last successful Search

Freeness Status:nf1 0nf2 0nf3 0nf4 0

 

Extent Map Block Offset: 4294967295

First free datablock : 3

Bitmap block lock opcode 0

Locker xid::0x0000.000.00000000

Inc #: 0 Objd: 54018

HWM Flag: HWM Set

Highwater::0x01c0000cext#: 0blk#: 3ext size: 8

#blocks in seg. hdr's freelists: 0

#blocks below: 0

mapblk0x00000000offset: 0

--------------------------------------------------------

DBA Ranges :

--------------------------------------------------------

0x01c00009Length: 8Offset: 0

0x01c00011Length: 8Offset: 8

 

0:Metadata1:Metadata2:Metadata3:unformatted

4:unformatted5:unformatted6:unformatted7:unformatted

8:unformatted9:unformatted10:unformatted11:unformatted

12:unformatted13:unformatted14:unformatted15:unformatted

--------------------------------------------------------

End dump data blocks tsn: 8 file#: 7 minblk 9 maxblk 9

*** 2009-12-07 19:35:44.296

Start dump data blocks tsn: 8 file#: 7 minblk 10 maxblk 10

buffer tsn: 8 rdba: 0x01c0000a (7/10)

scn: 0x0000.001a0dc1 seq: 0x01 flg: 0x04 tail: 0x0dc12101

frmt: 0x02 chkval: 0x5439 type: 0x21=SECOND LEVEL BITMAP BLOCK

Hex dump of block: st=0, typ_found=1

Dump of memory from 0x085C8400 to 0x085CA400

85C8400 0000A221 01C0000A 001A0DC1 04010000[!...............]

85C8410 00005439 00000000 00000000 00000000[9T..............]

85C8420 00000000 00000000 00000000 00000000[................]

Repeat 1 times

85C8440 00000000 00000000 00000000 01C0000B[................]

85C8450 00000008 00000008 00000000 00000000[................]

85C8460 00000000 00000000 0000D302 00000001[................]

85C8470 00000000 01C00009 00010005 01C00019[................]

85C8480 00010005 01C00029 00010005 01C00039[....).......9...]

85C8490 00010005 01C00049 00010005 01C00059[....I.......Y...]

85C84A0 00010005 01C00069 00010005 01C00079[....i.......y...]

85C84B0 00010005 00000000 00000000 00000000[................]

85C84C0 00000000 00000000 00000000 00000000[................]

Repeat 498 times

85CA3F0 00000000 00000000 00000000 0DC12101[.............!..]

Dump of Second Level Bitmap Block

number: 8nfree: 8ffree: 0pdba:0x01c0000b

Inc #: 0 Objd: 54018

opcode:0

xid:

L1 Ranges :

--------------------------------------------------------

0x01c00009Free: 5 Inst: 1

0x01c00019Free: 5 Inst: 1

0x01c00029Free: 5 Inst: 1

0x01c00039Free: 5 Inst: 1

0x01c00049Free: 5 Inst: 1

0x01c00059Free: 5 Inst: 1

0x01c00069Free: 5 Inst: 1

0x01c00079Free: 5 Inst: 1

 

--------------------------------------------------------

End dump data blocks tsn: 8 file#: 7 minblk 10 maxblk 10

Start dump data blocks tsn: 8 file#: 7 minblk 11 maxblk 11

buffer tsn: 8 rdba: 0x01c0000b (7/11)

scn: 0x0000.001a0dc6 seq: 0x01 flg: 0x04 tail: 0x0dc62301

frmt: 0x02 chkval: 0x79ad type: 0x23=PAGETABLE SEGMENT HEADER

Hex dump of block: st=0, typ_found=1

Dump of memory from 0x085C8400 to 0x085CA400

85C8400 0000A223 01C0000B 001A0DC6 04010000[#...............]

85C8410 000079AD 00000000 00000000 00000000[.y..............]

85C8420 00000000 00000010 00000080 00000A9C[................]

85C8430 00000000 00000003 00000008 01C0000C[................]

85C8440 00000000 00000000 00000000 00000000[................]

Repeat 1 times

85C8460 00000003 00000008 01C0000C 00000000[................]

85C8470 00000000 00000000 00000000 01C00009[................]

85C8480 01C00009 00000000 00000000 00000000[................]

85C8490 00000000 00000000 00000000 00000000[................]

Repeat 3 times

85C84D0 00000001 00002000 00000000 00001434[..... ......4...]

85C84E0 00000000 01C0000A 00000001 01C00079[............y...]

85C84F0 01C0000A 00000000 00000000 00000000[................]

85C8500 00000000 00000000 00000010 00000000[................]

85C8510 0000D302 10000000 01C00009 00000008[................]

85C8520 01C00011 00000008 01C00019 00000008[................]

85C8530 01C00021 00000008 01C00029 00000008[!.......).......]

85C8540 01C00031 00000008 01C00039 00000008[1.......9.......]

85C8550 01C00041 00000008 01C00049 00000008[A.......I.......]

85C8560 01C00051 00000008 01C00059 00000008[Q.......Y.......]

85C8570 01C00061 00000008 01C00069 00000008[a.......i.......]

85C8580 01C00071 00000008 01C00079 00000008[q.......y.......]

85C8590 01C00081 00000008 00000000 00000000[................]

85C85A0 00000000 00000000 00000000 00000000[................]

Repeat 144 times

85C8EB0 01C00009 01C0000C 01C00009 01C00011[................]

85C8EC0 01C00019 01C0001A 01C00019 01C00021[............!...]

85C8ED0 01C00029 01C0002A 01C00029 01C00031[)...*...)...1...]

85C8EE0 01C00039 01C0003A 01C00039 01C00041[9...:...9...A...]

85C8EF0 01C00049 01C0004A 01C00049 01C00051[I...J...I...Q...]

85C8F00 01C00059 01C0005A 01C00059 01C00061[Y...Z...Y...a...]

85C8F10 01C00069 01C0006A 01C00069 01C00071[i...j...i...q...]

85C8F20 01C00079 01C0007A 01C00079 01C00081[y...z...y.......]

85C8F30 00000000 00000000 00000000 00000000[................]

Repeat 144 times

85C9840 00000000 00000000 01C0000A 00000000[................]

85C9850 00000000 00000000 00000000 00000000[................]

Repeat 185 times

85CA3F0 00000000 00000000 00000000 0DC62301[.............#..]

Extent Control Header

-----------------------------------------------------------------

Extent Header:: spare1: 0spare2: 0#extents: 16#blocks: 128

last map0x00000000#maps: 0offset: 2716

Highwater::0x01c0000cext#: 0blk#: 3ext size: 8

#blocks in seg. hdr's freelists: 0

#blocks below: 0

mapblk0x00000000offset: 0

Unlocked

--------------------------------------------------------

Low HighWater Mark :

Highwater::0x01c0000cext#: 0blk#: 3ext size: 8

#blocks in seg. hdr's freelists: 0

#blocks below: 0

mapblk0x00000000offset: 0

Level 1 BMB for High HWM block: 0x01c00009

Level 1 BMB for Low HWM block: 0x01c00009

--------------------------------------------------------

Segment Type: 1 nl2: 1blksz: 8192fbsz: 0

L2 Array start offset:0x00001434

First Level 3 BMB:0x00000000

L2 Hint for inserts:0x01c0000a

Last Level 1 BMB:0x01c00079

Last Level II BMB:0x01c0000a

Last Level III BMB:0x00000000

Map Header:: next0x00000000#extents: 16obj#: 54018flag: 0x10000000

Inc # 0

Extent Map

-----------------------------------------------------------------

0x01c00009length: 8

0x01c00011length: 8

0x01c00019length: 8

0x01c00021length: 8

0x01c00029length: 8

0x01c00031length: 8

0x01c00039length: 8

0x01c00041length: 8

0x01c00049length: 8

0x01c00051length: 8

0x01c00059length: 8

0x01c00061length: 8

0x01c00069length: 8

0x01c00071length: 8

0x01c00079length: 8

0x01c00081length: 8

 

Auxillary Map

--------------------------------------------------------

Extent 0:L1 dba:0x01c00009 Data dba:0x01c0000c

Extent 1:L1 dba:0x01c00009 Data dba:0x01c00011

Extent 2:L1 dba:0x01c00019 Data dba:0x01c0001a

Extent 3:L1 dba:0x01c00019 Data dba:0x01c00021

Extent 4:L1 dba:0x01c00029 Data dba:0x01c0002a

Extent 5:L1 dba:0x01c00029 Data dba:0x01c00031

Extent 6:L1 dba:0x01c00039 Data dba:0x01c0003a

Extent 7:L1 dba:0x01c00039 Data dba:0x01c00041

Extent 8:L1 dba:0x01c00049 Data dba:0x01c0004a

Extent 9:L1 dba:0x01c00049 Data dba:0x01c00051

Extent 10:L1 dba:0x01c00059 Data dba:0x01c0005a

Extent 11:L1 dba:0x01c00059 Data dba:0x01c00061

Extent 12:L1 dba:0x01c00069 Data dba:0x01c0006a

Extent 13:L1 dba:0x01c00069 Data dba:0x01c00071

Extent 14:L1 dba:0x01c00079 Data dba:0x01c0007a

Extent 15:L1 dba:0x01c00079 Data dba:0x01c00081

--------------------------------------------------------

 

Second Level Bitmap block DBAs

--------------------------------------------------------

DBA 1:0x01c0000a

 

End dump data blocks tsn: 8 file#: 7 minblk 11 maxblk 11

 

 

附件:Show_space()存储过程代码:

 

CREATEORREPLACEPROCEDURE show_space (p_segname_1 IN varchar2,

p_space INvarchar2DEFAULT'MANUAL',

p_type_1 IN varchar2DEFAULT'TABLE',

p_analyzed INvarchar2DEFAULT'N',

p_owner_1 IN varchar2DEFAULTUSER

)

AS

p_segnameVARCHAR2(100);

p_typeVARCHAR2(10);

p_ownerVARCHAR2(30);

 

l_unformatted_blocksNUMBER;

l_unformatted_bytesNUMBER;

l_fs1_blocksNUMBER;

l_fs1_bytesNUMBER;

l_fs2_blocksNUMBER;

l_fs2_bytesNUMBER;

l_fs3_blocksNUMBER;

l_fs3_bytesNUMBER;

l_fs4_blocksNUMBER;

l_fs4_bytesNUMBER;

l_full_blocksNUMBER;

l_full_bytesNUMBER;

 

l_free_blksNUMBER;

l_total_blocksNUMBER;

l_total_bytesNUMBER;

l_unused_blocksNUMBER;

l_unused_bytesNUMBER;

l_lastusedextfileidNUMBER;

l_lastusedextblockidNUMBER;

l_last_used_blockNUMBER;

 

PROCEDUREp(p_label INvarchar2, p_num INnumber)

IS

BEGIN

DBMS_OUTPUT.put_line (RPAD(p_label,40,'.') || p_num);

END;

BEGIN

p_segname:=UPPER(p_segname_1);-- rainy changed

p_owner:=UPPER(p_owner_1);

p_type:= p_type_1;

 

IF(p_type_1 ='i'OR p_type_1 ='I')

THEN--rainy changed

p_type:='INDEX';

ENDIF;

 

IF(p_type_1 ='t'OR p_type_1 ='T')

THEN--rainy changed

p_type:='TABLE';

ENDIF;

 

IF(p_type_1 ='c'OR p_type_1 ='C')

THEN--rainy changed

p_type:='CLUSTER';

ENDIF;

 

 

DBMS_SPACE.unused_space (segment_owner => p_owner,

segment_name => p_segname,

segment_type => p_type,

total_blocks => l_total_blocks,

total_bytes => l_total_bytes,

unused_blocks => l_unused_blocks,

unused_bytes => l_unused_bytes,

last_used_extent_file_id => l_lastusedextfileid,

last_used_extent_block_id => l_lastusedextblockid,

last_used_block => l_last_used_block

);

 

IF p_space ='MANUAL'OR(p_space <>'auto'AND p_space <>'AUTO')

THEN

DBMS_SPACE.free_blocks (segment_owner => p_owner,

segment_name => p_segname,

segment_type => p_type,

freelist_group_id =>0,

free_blks => l_free_blks

);

 

p('Free Blocks', l_free_blks);

ENDIF;

 

p('Total Blocks', l_total_blocks);

p('Total Bytes', l_total_bytes);

p('Unused Blocks', l_unused_blocks);

p('Unused Bytes', l_unused_bytes);

p('Last Used Ext FileId', l_lastusedextfileid);

p('Last Used Ext BlockId', l_lastusedextblockid);

p('Last Used Block', l_last_used_block);

 

 

/*IF the segment is analyzed */

IF p_analyzed ='Y'

THEN

DBMS_SPACE.space_usage (segment_owner => p_owner,

segment_name => p_segname,

segment_type => p_type,

unformatted_blocks => l_unformatted_blocks,

unformatted_bytes => l_unformatted_bytes,

fs1_blocks => l_fs1_blocks,

fs1_bytes => l_fs1_bytes,

fs2_blocks => l_fs2_blocks,

fs2_bytes => l_fs2_bytes,

fs3_blocks => l_fs3_blocks,

fs3_bytes => l_fs3_bytes,

fs4_blocks => l_fs4_blocks,

fs4_bytes => l_fs4_bytes,

full_blocks => l_full_blocks,

full_bytes => l_full_bytes

);

DBMS_OUTPUT.put_line (RPAD(' ',50,'*'));

DBMS_OUTPUT.put_line ('The segment is analyzed');

p('0% -- 25% free space blocks', l_fs1_blocks);

p('0% -- 25% free space bytes', l_fs1_bytes);

p('25% -- 50% free space blocks', l_fs2_blocks);

p('25% -- 50% free space bytes', l_fs2_bytes);

p('50% -- 75% free space blocks', l_fs3_blocks);

p('50% -- 75% free space bytes', l_fs3_bytes);

p('75% -- 100% free space blocks', l_fs4_blocks);

p('75% -- 100% free space bytes', l_fs4_bytes);

p('Unused Blocks', l_unformatted_blocks);

p('Unused Bytes', l_unformatted_bytes);

p('Total Blocks', l_full_blocks);

p('Total bytes', l_full_bytes);

ENDIF;

END;

 

exec show_space('abc','auto','T','Y');

分享到:
评论

相关推荐

    Oracle数据库中利用ASSM改善分段存储

    表格空间增强了自动分段空间管理(ASSM),ASSM的tablespace是通过将SEGMENT SPACE MANAGEMENT AUTO子句添加到tablespace的定义句法里而实现的。通过使用位图freelist取代传统单向的链接列表freelist,ASSM的...

    Oracle数据文件收缩实例

    近期来,FreeList的重要作用逐渐为Oracle DBA所认识... ASSM:auto segement space management HWM:high water mark DBA:data block address OLTP:online transaction process OPS:oracle parallel server

    Oracle自动内存管理ASMM

    Oracle 自动内存管理 ASMM assm的内部特性值得一看

    Oracle9i自动分段空间管理改善分段存储

    文中介绍了Oracle9i增强了本地管理减轻了数据字典的负担、增强了自动分段空间管理(ASSM),因此能够改善分段存储本质。

    Oracle11g Memory&Storage Overview

    本ppt较为系统的介绍了Oracle11g的内存与存储管理,主要目录如下: 1.Memory Overview:  --SGA Parameters  --Automatic Shared Memory Management  --Oracle 11g参数设置建议  --Oracle Database Memory ...

    oracle-dmt-lmt-mssm-assm

    dmt,lmt是管理segment中的extent的,而mssm和assm是管理extent中的block的。 需要说明的时不论在dmt还时lmt下都可以使用mssm,而在dmt下只能使用mssm,而下面要介绍的assm只在lmt下才支持。

    Oracle DBA笔试及面试题汇总

     3:本地管理表空间和字典管理表空间的特点,ASSM有什么特点?  4:备份如何分类?  5:如果一个表被drop,在有完善的归档和备份的情况下,如何恢复  6:rman是什么,有何特点?  7:standby的特点  8:对于一个...

    oracle truncate恢复

    block type=0×23 (ASSM segment header block) block format=0×02 (oracle 8 or 9) block rdba=0×02800578 (file#=10, block#=1400) scn=0×0000.00286f2d, seq=4, tail=0×6f2d2304 block checksum value=0×0=0...

    ITPUB电子杂志

    关于shared pool的深入探讨 32bit oracle扩展SGA原理 32bit oracle中SGA_MAX_SIZE与单个进程PGA的制约关系 bitmap索引的一点探究 关于B*tree索引(index)的中度理解 本地管理表空间 倾力大奉献--...

    OCM考试全面解析及经验分享

    OCM考试全称为Oracle Certified Master(Oracle认证大师),是在OCA(Oracle认证专员Oracle Certified Associate)、OCP(Oracle认证专家Oracle Certified Professional)之后更高一级的Oracle技术认证,也是Oracle技术...

    Assm.rar_SIC ASSEMBLER_ob_sic_two-pass assembler

    sic assembler output pass one and pass two finally, put ob file

    (E文)基于成本的Oracle优化法则.pdf

    5.1.3 减少表的争用(ASSM) 92 5.1.4 减少RAC中的争用 (自由列表群) 95 5.2 列顺序 96 5.3 额外的列 99 5.4 校正统计信息 101 5.4.1 sys_op_countchg()技术 101 5.4.2 非正式策略 105 5.5 待处理的零碎问题 106 5.6 ...

    assm.rar_Micro Mechanical_level set_level set模拟_水平集_水平集 三维

    应用三维Level Set数值模拟技术实现硅基微机械湿法刻蚀仿真研究\LevelSetMethods水平集源码

    assm-2014-10-20.zip_单片机开发_Visual_C++_

    Assigment 1 bk_2014Chu tho va nhung nguoi ban

    ansysworkbench设置材料属性.doc

    ansysworkbench设置材料属性.doc

    电机优化计算 matlab maxwell Simplorer,目标最优化求解

    以一台130口径ASSM为例,对电机的永磁体形状和槽口宽进行了参数化扫描分析sweep ansys,并以齿槽转矩为目标函数进行了最优化optimization求解;在Maxwall 3D瞬态场下对永磁电机控制影响较大的电感参数Ld、Lq进行了...

    带工程图另存外挂.swp

    本软件实际上是一个SolidWorks的宏文件,旨在sw的part和assm模型另存时,如果原模型已经存在关联的工程图,另存为其他名称时连带原模型关联的工程图一并另存;并且关联到另存模型. 帮助工程师提高软件的使用效率. 1.选择...

Global site tag (gtag.js) - Google Analytics