Hi! Welcome back. Part 1 of this series discussed how to dump blocks, how to find the segment header and started to take a look at the internal block representation of a data block. Part 1 also made reference to the segment header. This article will discuss the internals of data block management. When a full-table scan is initiated, Oracle finds the segment header, locates the first extent (first block in the extent using the database address, the DBA which is file number and block number). Oracle reads the entire extent into memory for block by block processing. The block by block processing (or a full table scan) is known internally (and shows up as a wait event) as DB File Scattered Read as the data blocks are loaded into memory where there is available room for them. I just did a blog on ROWID and using the file number and block number to locate blocks on disk. If you have not read that blog entry yet, now might be a good time to do so. A segment header is always the first block of an object. The segment header has 6 major areas: Extent control header map header extent map Low High Water Mark High High Water Mark An 8K block can manage 307 extents. Once the object grows beyond this size, Oracle chains on another block to this segment header that will then manage another 307 extents. All that is needed to find the chained segment header is the database address (the DBA…file number and block number) of the next set of extents. The extent control header contains the number of extents allocated to this segment, the number of blocks allocated to the segment, DBA of the last block of the extent map (0 if no UNLIMITED EXTENTS is used), number of extent map blocks, low high water mark (low HWM) extent number, high HWM extent number, and HWM block number within the extent. The extent header also contains a nibble (a single bit) that contains the storage availability of each block in the extent. Automatic Space Storage Management was implemented in Oracle8i and became the default setting for extent management starting in Oracle9. . This feature replaces the free lists and free list groups (used by RAC). It manages free space with bits in 25% increments. This additional information is stored in the segment header so the extent header holds less extents but more useful information about where available space is in the extent map. Free space and blocks that meet PCTFREE are now tracked in the segment header. PCTUSED, or, how empty does the block become before it can have inserts again…is now ignored. The DBA’s have a command (I think it involves the shrink comment…you DBA types…let me know the command that re-aligns free space settings for a table object). ASSM doesn’t format the whole file when it is added (as is the case with regular tablespace files…) but formats like 16 blocks at a time and uses a low high water mark and a high high water mark to keep track of the blocks that are getting current inserts. Bitmap blocks store the PCTFREE and status of the blocks (used, full, unformatted, etc). These are the status’s of the bits. Notice that PCTFREE is in 25% increments and Oracle will round up to the next level based on what appears in the object’s storage clause. Oracle will work on a formatted block at a time, between the 2 high water marks. It will fill the first up to the first PCTFREE increment, then hop to the next block and do the same thing…once all are at 25% full, it repeats the process until all the blocks are at the desired PCTFREE. Then, Oracle will format the next 16 blocks and move the high water marks and repeat the process. This feature is designed to aid the automatic space management (adding of files, etc) in a more rapid fashion. I believe it also helps large applications that have a lot of concurrent inserts. Next month we return to data block internals and how Oracle manages multiple updates in the same data block. Dan Hotka Oracle ACE Director Author/Instructor/CEO
↧