Saturday, May 19, 2012

Oracle Storage Hierarchy

Segments are database objects (table, index, rollback, temproary, cluster segments etc) that consume storage.  Segment contains one or more extents.  An extent is a logically contiguous allocatiom of space in a file.  Some segments start with 1 extent.  Some segments start with 2 extents (e.g. rollback segment).  Extent contains blocks, which are the smallest unit of allocation in Oracle.  Block is also the unit of I/O in Oracle.

Database may have more than 1 block size.  This is mainly used for the purpose of data transportation than anything else.  Tablespaces have only 1 consistent block size although the segments inside can have mutluple size.

Block contains a header which indicates the block type (table, index etc), transaction information regarding active or past transactions on the block and address on the disk.  After that is Table Directory whcih contains information about the tables that store rows in this block.  After that is Row Directory describing the rows stored in the block.  After that is an array containing pointers to the actual rows in the block.  The rest of the block contains data and free space.

Database comprises tablespaces.  Tablespace is a container that holds segements. Segments never cross tablespace boundary.  Tablespaces comprises one or more files.   Files can be raw or cooked file systems.  An extent within a segment will be contained entirely within one file.  A segment can have extents from different files.

In summary:
  • Database contains tablespaces
  • Tablespace contains segements
  • Tablespace contains files
  • Segment contains extents
  • File contains extents
  • Extent contains blocks

No comments: