Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

rekharaghuram
from rekharaghuram More from this publisher
05.11.2015 Views

CHAPTER 3 ■ FILES 91 Redundant Array of Independent Disks (RAID), you might find a single file is not only not contiguous on a single disk, but also spans many physical disks. Every segment starts with at least one extent, and some objects may require at least two (rollback segments are an example of a segment that require at least two extents). For an object to grow beyond its initial extent, it will request another extent be allocated to it. This second extent will not necessarily be located right next to the first extent on disk—it may very well not even be allocated in the same file as the first extent. The second extent may be located very far away from the first extent, but the space within an extent is always logically contiguous in a file. Extents vary in size from one Oracle data block to 2GB. Blocks Extents, in turn, consist of blocks. A block is the smallest unit of space allocation in Oracle. Blocks are where your rows of data, or index entries, or temporary sort results will be stored. A block is what Oracle generally reads from and writes to disk. Blocks in Oracle are generally one of four common sizes: 2KB, 4KB, 8KB, or 16KB (although 32KB is also permissible in some cases; there are restrictions in place as to the maximum size by operating system). ■Note Here’s a little-known fact: the default block size for a database does not have to be a power of two. Powers of two are just a convention commonly used. You can, in fact, create a database with a 5KB, 7KB, or nKB block size, where n is between 2KB and 32KB. I do not advise making use of this fact in real life, though— stick with 2KB, 4KB, 8KB, or 16KB as your block size. The relationship between segments, extents, and blocks is shown in Figure 3-1. Figure 3-1. Segments, extents, and blocks A segment is made up of one or more extents, and an extent is a contiguous allocation of blocks. Starting with Oracle9i Release 1, a database may have up to six different block sizes in it.

92 CHAPTER 3 ■ FILES ■Note This feature of multiple block sizes was introduced for the purpose of making transportable tablespaces usable in more cases. The ability to transport a tablespace allows a DBA to move or copy the already formatted data files from one database and attach them to another—for example, to immediately copy all of the tables and indexes from an Online Transaction Processing (OLTP) database to a Data Warehouse (DW). However, in many cases, the OLTP database might be using a small block size, such as 2KB or 4KB, whereas the DW would be using a much larger one (8KB or 16KB). Without support for multiple block sizes in a single database, you would not be able to transport this information. Tablespaces with multiple block sizes should be used to facilitate transporting tablespaces and are not generally used for anything else. There will be the database default block size, which is the size that was specified in the initialization file during the CREATE DATABASE command. The SYSTEM tablespace will have this default block size always, but you can then create other tablespaces with nondefault block sizes of 2KB, 4KB, 8KB, 16KB and, depending on the operating system, 32KB. The total number of block sizes is six if and only if you specified a nonstandard block size (not a power of two) during database creation. Hence, for all practical purposes, a database will have at most five block sizes: the default size and then four other nondefault sizes. Any given tablespace will have a consistent block size, meaning that every block in that tablespace will be the same size. A multisegment object, such as a table with a LOB column, may have each segment in a tablespace with a different block size, but any given segment (which is contained in a tablespace) will consist of blocks of exactly the same size. All blocks, regardless of their size, have the same general format, which looks something like Figure 3-2. Figure 3-2. The structure of a block The block header contains information about the type of block (table block, index block, and so on), transaction information when relevant (only blocks that are transaction managed have this information—a temporary sort block would not, for example) regarding active and past transactions on the block, and the address (location) of the block on the disk. The next two block components, table directory and row directiry, are found on the most common types of database blocks, those of HEAP organized tables. We’ll cover database table types in much more detail in Chapter 10, but suffice it to say that most tables are of this type. The table directory, if present, contains information about the tables that store rows in this block

CHAPTER 3 ■ FILES 91<br />

Redundant Array of Independent Disks (RAID), you might find a single file is not only not contiguous<br />

on a single disk, but also spans many physical disks. Every segment starts with at least<br />

one extent, <strong>and</strong> some objects may require at least two (rollback segments are an example of a<br />

segment that require at least two extents). For an object to grow beyond its initial extent, it will<br />

request another extent be allocated to it. This second extent will not necessarily be located<br />

right next to the first extent on disk—it may very well not even be allocated in the same file as<br />

the first extent. The second extent may be located very far away from the first extent, but the<br />

space within an extent is always logically contiguous in a file. Extents vary in size from one<br />

<strong>Oracle</strong> data block to 2GB.<br />

Blocks<br />

Extents, in turn, consist of blocks. A block is the smallest unit of space allocation in <strong>Oracle</strong>.<br />

Blocks are where your rows of data, or index entries, or temporary sort results will be stored.<br />

A block is what <strong>Oracle</strong> generally reads from <strong>and</strong> writes to disk. Blocks in <strong>Oracle</strong> are generally<br />

one of four common sizes: 2KB, 4KB, 8KB, or 16KB (although 32KB is also permissible in some<br />

cases; there are restrictions in place as to the maximum size by operating system).<br />

■Note Here’s a little-known fact: the default block size for a database does not have to be a power of two.<br />

Powers of two are just a convention commonly used. You can, in fact, create a database with a 5KB, 7KB, or<br />

nKB block size, where n is between 2KB <strong>and</strong> 32KB. I do not advise making use of this fact in real life,<br />

though— stick with 2KB, 4KB, 8KB, or 16KB as your block size.<br />

The relationship between segments, extents, <strong>and</strong> blocks is shown in Figure 3-1.<br />

Figure 3-1. Segments, extents, <strong>and</strong> blocks<br />

A segment is made up of one or more extents, <strong>and</strong> an extent is a contiguous allocation of<br />

blocks. Starting with <strong>Oracle</strong>9i Release 1, a database may have up to six different block sizes in it.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!