Oracle space management experiment

Source: Internet
Author: User
The experiment is divided into two steps: 1. LMT local management of the tablespace, ASSM automatic segment management data file structure analysis Oracle11G: 0 operating system block, 1-2 is the file header, 3-127 is a bit

The experiment is divided into two steps: 1. LMT local management of the tablespace, ASSM automatic segment management data file structure analysis Oracle 11G: 0 operating system block, 1-2 is the file header, 3-12 7 is a bit

The experiment is divided into two steps:
1. LMT local management of tablespaces, ASSM automatic segment management when the data file structure analysis Oracle 11G: 0 operating system block, 1-2 is the file header, 3-127 is the bitmap information. Data is stored at the beginning and end of 128-it may be the data of the segment header or segment.
When ORACLE is 10 Gb, there are only 8 data file headers to store bitmap information. -- This article has not been tested.

2. Record of the usage of the partition in the bitmap block-block 3 is used in the first record area. This article describes Block 3. The bitmap block uses the binary value 1 to indicate the start number of a partition-or the position of the first allocable partition. The number of partitions in this record does not matter with the automatic or fixed partition size. You can create two tablespaces for verification by creating two different allocation methods.

In combination with the experiment, I understand that the bitmap represents the location of the partition, not the absolute location of DBA, but the relative location of the first few, when allocating, El finds the first available area based on the information in the bitmap block. -- I don't know if this is correct. If you cannot figure it out, let's look at the experiment later.

3. Which operations will release space? What do I do when a space is released?

Bitmap changes when a segment is deleted: If the segment is dropped or TRUNCATE, the corresponding partition is recycled. If only the DELETE data is deleted, the partition space will not be recycled-the space in the data block will not be recycled-high water level.

For example, table A of partition 1, 2, 3, 4, and 5 where TRUNCATE Zone 2 is located,
Truncate table a; DDL operation, perform a full checkpoint, and then DUMP the data file No. 3 in the record area in the bitmap. It is found that FIRST has changed and zone space is released.
It is the change in the line information of Block 3 of the DUMP data file: RelFno: 14, BeginBlock: 128, Flag: 0, First: 1, Free: 63487

4. Whether to enable the flash back DROP recycle bin function to verify the different ways in which Oracle looks for zones:

Enable the flash back DROP recycle bin function-11 GB is enabled by default. For example, if a data file contains multiple segments (tables), the table creation sequence is different, the allocated partition has different data files. In this case, if you drop the First table created in the data file and DUMP the bitmap block, you will find that the value of First: 4 will change to First: 1, and then there may be a very long time before ffffffff0f00. However, it is said that when flash back is enabled, the search for a zone scans the entire bitmap. The value of First: 4 is useless. After drop, the table system command rename, And the partition and data still exist in the data file. If no zone is available for the entire bitmap area, the earliest drop zone will be released at the drop time. If the space of all the tables in the recycle bin is released, the data file will be extended.

If the recycle bin function of the flash-back DROP is not enabled, if the First table on the data file is deleted or TRUNCATE, the value of First: 4 in the bitmap will not change, it will be allocated directly from First: 4, until the data file is allocated completely, it will return to the beginning to find free.

Note: The calculation method of the record used in the bitmap is as follows:
DUMP this block, you can see the following:
RelFno: 7, BeginBlock: 128, Flag: 0, First: 4, Free: 63451
0F00000000000000
This is because, in a block, hexadecimal is used to represent the binary system. We should convert the hexadecimal system into a binary system, and check the number of binary 1 to calculate the number of the starting zone.
A simpler calculation method is: Each hexadecimal represents a maximum of four 1 s, which are hexadecimal 1 -- binary 1, hexadecimal 3 -- binary 11, hexadecimal 7 -- binary 11, hexadecimal F -- binary 1111
Here, 0F is four binary 1, which indicates that four partitions are allocated.


Step 1 of the experiment: analyze the structure of data files in the tablespace locally managed by LMT and ASSM automatic segment Management

Create a new table space test4, create a new data file in the table space test4, insert a row of data, and make a full checkpoint. You can find the position of the segment header from dba_segments.header_block, blocks 1-4 and 127-131 of the DUMP test4 tablespace.

BYS @ bys3> create table test4 (aa int) tablespace test4;
Table created.
BYS @ bys3> insert into test4 values (99889 );
1 row created.
BYS @ bys3> commit;
Commit complete.
BYS @ bys3> select segment_name, header_block, header_file, blocks from dba_segments where segment_name = 'test4 ';
SEGMENT_NAME HEADER_BLOCK HEADER_FILE BLOCKS
------------------------------------------------
TEST4 130 14 8
BYS @ bys3> alter system checkpoint; --- make a full check point. Otherwise, the newly inserted data is not written into the data file.
System altered.
#############
BYS @ bys3> alter system dump datafile 14 block min 1 block max 4;
System altered.
BYS @ bys3> select value from v $ diag_info where name like 'de % ';
VALUE
Bytes ----------------------------------------------------------------------------------------------------
/U01/diag/rdbms/bys3/bys3/trace/bys3_ora_12335.trc
BYS @ bys3> alter system dump datafile 14 block min 127 block max 131;
System altered.
BYS @ bys3> select value from v $ diag_info where name like 'de % ';
VALUE
Bytes ----------------------------------------------------------------------------------------------------
/U01/diag/rdbms/bys3/bys3/trace/bys3_ora_12377.trc
################

DUMP data block content analysis

Part 2: -- Bitmap header

Start dump data blocks tsn: 9 file #: 14 minblk 1 maxblk 4

Block 1 (file header) not dumped: use dump file header command -- DUMP data file 1st blocks -- Block header, use alter system set events 'immediate trace name file_hdrs level 3 ';
Block dump from cache: -- this is from the buffer cache.
Dump of buffer cache at level 4 for tsn = 9 rdba = 58720258
BH (0x217f7538) file #: 14 rdba: 0x03800002 (14/2) class: 13 ba: 0x2171c000 -- For details about BH, see: detailed description of Buffer Header-DUMP buffer combined with various fields in the X $ BH View
Set: 3 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0, 0
Dbwrid: 0 obj:-1 objn: 1 tsn: 9 afn: 14 hint: f
Hash: [0x2a000041c, 0x2a000041c] lru: [0x22fed538, 0x22fe44d8]
Ckptq: [NULL] fileq: [NULL] objq: [0x24444154, 0x22fe44f0] objaq: [0x2444414c, 0x22fe44f8]
St: XCURRENT md: NULL fpin: 'kt fbwh0d: KT fbsearch' tch: 2
Flags: block_written_once redo_since_read
LRBA: [0x0. 0.0] LSCN: [0x0.0] HSCN: [0xffff. ffffffff] HSUB: [1]
Block dump from disk:
Buffer tsn: 9 rdba: 0x03800002 (14/2) ------ tsn: 9 tablespace number, rdba: 0x03800002 (14/2) 14 file No. 2
Scn: 0x0000. 0077 dfdb seq: 0x02 flg: 0x04 tail: 0xdfdb1d02
Frmt: 0x02 chkval: 0xb96b type: 0x1d = KTFB Bitmapped File Space Header -- the information of this block is a bitmap block.
Hex dump of block: st = 0, typ_found = 1
Dump of memory from 0xB6C22600 to 0xB6C24600
B6C22600 running a30d 03800002 0077 DFDB 04020000 [......]
B6C22610 116b96b 0000000E 00000008 00000500 [k ......]
B6C22620 00000001 00000000 00000000 2017007e [......]
B6C22630 000004FF 00000001 0000008F 00000003 [......]
B6C22640 00000000 00000000 00000000 00000000 [......]
B6C22650 00000080 00000008 00000000 00000000 [......]
B6C22660 00000000 00000000 00000000 00000000 [......]
Repeat 504 times
B6C245F0 00000000 00000000 00000000 DFDB1D02 [......]
File Space Header Block:
Header Control:
RelFno: 14, Unit: 8, Size: 1280, Flag: 1 --- relative file number 14, Unit: 8 -- Allocation Unit. The Size of each block is 8192 ,. Size: 1280 -- Size of the data file-1280*8 K = 10 M
AutoExtend: NO, Increment: 0, MaxSize: 0 ---
Initial Area: 126, Tail: 1279, First: 1, Free: 143 --- Initial Area: 126, which indicates that there are 126 blocks used to record bitmap information -, from 3 to 127-11g, there are 6
Deallocation scn: 3.0
Header Opcode:
Save: No Pending Op
Block dump from cache:

Dump of buffer cache at level 4 for tsn = 9 rdba = 58720259 -- TNS9 is the tablespace number and rdba = 58720259 is the FILE and BLOCK. The RDBA calculation method is as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.