Oracle Data blocks,extents,segments

Source: Internet
Author: User

Reproduced

Let's look at data blocks (also called logical block, Oracle block, page), where Oracle stores data in these chunks, and a block of data is the composition of a series of physical bytes in the physical space of the database on disk.
A higher level of logical data block space than data blocks is extent, a extent consists of a series of contiguous data blocks that store information.
The logical structure of the highest layer is segment, and a segment is a collection of extents in the same tablespace. Each segment has a different data structure. Each table is stored in its own data segment, and each index is stored in its own index segment, if the table or index is
is partitioned, each partition is stored in their respective segment. A segment and all of his extent are in a tablespace, and a segment can span several data files.

For a database, data block is the smallest storage unit allocated and private in the Oracle database. But this is only for the database, at the physical level, the operating system level, all the data is still stored in bytes. Each operating system has its own chunk size (block size), in the Oracle database, the size of the data block has parameters db_block_size when the database is created to determine that his value should be an integer multiple of the operating system block size.
Data blocks are made up of a few parts, the chunk, the table directory, the row directory, the free space, and the data. The size of the block consists mainly of two parts: the type of the header address and the segment, the data table or the index, and the table directory that contains the number of rows of data. The row directory primarily contains the physical address of each row. The data is obvious, which is the data contained in this block. Here is the most wonderful is this free space, its main purpose is to varchar this data type prepared, there are two threshold parameter pctfree,pctused to control this data to the linked list, the two parameters are set up primarily to avoid row connection and row migration, Concrete enough an article, and then write, ^_^.
In terms of extent this consists of a series of contiguous data blocks. Whenever a table is created in the database, the data segment assigned to the table is assigned an initial extent that contains several databases, although the initial extent is ready to insert it, even though the data has not been plugged in. If the data block in the initial extent is full, or there is no space to insert the data, then he will expand incrementally. Of course, this is only a case of serial execution, which is not appropriate for concurrency. Some storage parameters control how Oracle allocates free space for each segment. When creating a table using CREATE TABLE, the storage parameter determines how much free space is allocated or limits how many extents the table can contain, and if these parameters are not defined when the table is created, the default storage parameters defined by the tablespace are used. For tables that are frequently inserted and deleted, DBAs can use this statement to recover useless extent, Aler table table_name deallocate unused;


Here segment, each segment is a logical storage structure with a series of extent in a table space. For example, when a database user creates a table, Oracle assigns one or more extent to form the data segment of the table, creates an index, and Oracle will extent to the index data. Generally can be divided into data segment,index segment,temporary segment.
When you create a non-partitioned and non-focused table, or a partition of a partitioned table, a cluster of multiple tables is a single data segment that Oracle will process the data.
An index segment, for a non-partitioned index, is that the indexes created by the CREATE index assign a segment to process the data, and the partitioned index assigns a segment to each partition to process the data.
When a process queries, Oracle often needs a temporary workspace to hold the intermediate state of SQL parsing and execution, and Oracle automatically allocates disk space temporary segment. In particular, Oracle assigns a temporary segment when the sort area of the memory is insufficient. Sometimes, some of the following statements need to use temporary segment:
Create INDEX ....
Select .... order by;
SELECT DISTINCT ....
Select ... Group by
Select ... union
Select ... intersect
Select ... minus
There is also a sub-query will also use the temporary segment. If a query contains a DISTINCT clause, an order BY, and a group by, then two temporary segment are required. When creating a temporary table or index, Oracle also assigns some temporary segment.
For temporary segment,oracle is allocated only in a session of a user, but the SQL statement execution ends or the session disconnects, all temporary segment are released. The disk space allocated for these temporary segment is in a temporary tablespace, and if no temporary table space is defined, the default temporary tablespace will be the system table space. For DBAs, the allocation and release of these temporary segment will be very frequent, so at least one temporary segment must be defined to avoid fragmentation of the system table space. For temporary tables, if multiple sessions are common to a temporary table, then the temporary segment of the temporary table allocation will be released if all sessions are known to end.

Oracle Data blocks,extents,segments

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.