Monday 17 October 2011

Index-Organized Table, Difference bw Ordinary Table & Index-Organized Table

An index-organized table has a storage organization that is a variant of a primary B-tree. Unlike an ordinary (heap-organized) table whose data is stored as an unordered collection (heap), data for an index-organized table is stored in a B-tree index structure in a primary key sorted manner. Besides storing the primary key column values of an index-organized table row, each index entry in the B-tree stores the nonkey column values as well.
Ordinary Table Index-Organized Table
Rowid uniquely identifies a row. Primary key can be optionally specified Primary key uniquely identifies a row. Primary key must be specified
Physical rowid in ROWID pseudocolumn allows building secondary indexes Logical rowid in ROWID pseudocolumn allows building secondary indexes
Access is based on rowed Access is based on logical rowid
Sequential scan returns all rows Full-index scan returns all rows
Can be stored in a cluster with other tables Cannot be stored in a cluster
Can contain a column of the LONG datatype and columns of LOB datatypes Can contain LOB columns but not LONG columns

Index-organized tables provide faster access to table rows by the primary key or any key that is a valid prefix of the primary key. Presence of nonkey columns of a row in the B-tree leaf block itself avoids an additional block access. Also, because rows are stored in primary key order, range access by the primary key (or a valid prefix) involves minimum block accesses. Because rows are stored in primary key order, a significant amount of additional storage space savings can be obtained through the use of key compression. Use of primary-key based logical rowids, as opposed to physical rowids, in secondary indexes on index-organized tables allows high availability. This is because, due to the logical nature of the rowids, secondary indexes do not become unusable even after a table reorganization operation that causes movement of the base table rows. At the same time, through the use of physical guess in the logical rowid, it is possible to get secondary index based index-organized table access performance that is comparable to performance for secondary index based access to an ordinary table.

No comments:

Post a Comment