A data block consists of three parts: the block header, the free zone, and the data zone. As the amount of data increases, the top part occupies the free zone while the data zone occupies the free zone. When the two parts are in contact, the data block is full.
Data zone: stores data rows. when data is inserted, the data occupies the free zone from the bottom up.
Block header: stores the address, table directory, row directory, and transaction slot of the data block. The transaction slot is used when the transaction modifies the data. The header occupies the free zone from top to bottom
Idle zone: It is located in the middle of the data block and is continuous during initialization. However, with the deletion and modification operations, the Free Zone is fragmented. The Oracle Server merges free zones as needed.
1. Oracle introduces four parameter management data blocks
1. Parameters for controlling parallel operations: initrans and maxtrans
Each data row in the data block has a lock in the header, which records the transaction slot number used by the Data row in the transaction. The transaction slot is in the header of the data block, and the transaction control information is placed in the transaction slot.
The Oracle server finds the corresponding transaction slot in the data block header Through the transaction slot number in the lock bit of each row, and uses the information in the slot to complete the transaction control of the row.
The transaction slot is used to store the information related to the transaction that changes the data block. Each transaction can only use one transaction slot even if the transaction is modifying multi-row data or multi-row index records.
Initrans: defines the initial value of creating a data block or index block's current affairs slot to ensure the lowest level of parallel operations
Maxtrans: defines the maximum value for creating a data block or index block event slot. As parallel transactions increase, the number of transaction slots in the data block header also increases. This value specifies the maximum number of transaction slots.
Note: parallel operations and data block space utilization are in conflict. If the initrans and maxtrans values are too large, the efficiency of the transaction parallel row system is also improved, however, the increase in the number of transaction slots in the data block header reduces the data Zone capacity. Do not change their default values unless necessary.
2. parameters used to control data space:
Pctfree and pctused
2. Oracle provides two methods to manage data blocks: manual management and automatic segment space management.
(1) Management of manual data blocks
Manual data block management is the default space management method of Oracle. Oracle manually configures data blocks by modifying the parameters to manage and control disk space usage more effectively.
1. pctfree: defines the percentage of Space reserved in the data block. This part of data space is used only when the data row in the data block is modified.
2. pctused: defines the percentage of space used in the data block. Oracle puts the data block into the idle queue only when the percentage of space used in the data block is smaller than this value.
3. freelists: used to define the number of idle queues in a segment. The number of idle queues is a list of data blocks. These data blocks will be used as candidate data blocks for the insert operation.
For example, when pctfree = 15 and pctused = 30 are set, the Oracle server space is allocated as follows:
1. During data insertion, the Oracle server needs to retain 15% of the free space of the total data block space, which will be used for resizing due to future modification operations.
2. When the free space is less than or equal to 15%, the Oracle server removes the data block from the free queue and cannot insert it.
3. If the disk space is reduced due to deletion or modification, although the free space is greater than 15% but the used space is greater than 30%, the disk space cannot be inserted.
4. This block is re-inserted into the idle queue only when the used space is smaller than pctused = 30%. insertion is allowed.
Note: The purpose of introducing pctfree and pctused is to avoid system bumps. Therefore, data blocks must be empty to a certain extent before they can be inserted. If only one pctfree parameter is used, data can be inserted again when the free space is greater than 15%. Once the data is inserted, the free space is less than 16%, it is removed from the idle queue again. This may happen frequently, that is, system bumps. The default Oracle parameters pctfree, pctused, and freelists should not be modified unless necessary, because most Oracle parameters are correlated, if the modification is poor, the system efficiency will be low.
(2) automatic segment space management
This method uses bitmap instead of idle queues to track idle and used data blocks in segments. This method has the following advantages:
1. Convenient management. Both pctfree and freelists are automatically managed.
2. Good space utilization
3. The performance of parallel insert operations has been greatly improved.
The automatic segment management method can only take effect at the tablespace level, and automatic segment management can be enabled only when the tablespace is locally managed. This configuration is applied to all segments in the tablespace.
When creating a tablespace, you can use the segment space management auto clause to complete automatic segment space management configuration.
Automatically managed segments can be common tables, indexes, index tables, or large object segments.
Note: The data dictionaries used to obtain disk management information of segments include dba_tablespaces, dba_data_files, dba_extents, dba_segments, and dba_free_space.
Summary: Oracle data blocks: the smallest storage unit in Oracle. Oracle data blocks are database systems.