Overview of Hash Clusters (239)

tsinglee發表於2007-11-21

Hash clusters group table data in a manner similar to regular index clusters (clusters
keyed with an index rather than a hash function). However, a row is stored in a hash
cluster based on the result of applying a hash function to the row’s cluster key value.
All rows with the same key value are stored together on disk.

Hash clusters are a better choice than using an indexed table or index cluster when a
table is queried frequently with equality queries (for example, return all rows for
department 10). For such queries, the specified cluster key value is hashed. The
resulting hash key value points directly to the area on disk that stores the rows.

Hashing is an optional way of storing table data to improve the performance of data
retrieval. To use hashing, create a hash cluster and load tables into the cluster. Oracle
physically stores the rows of a table in a hash cluster and retrieves them according to
the results of a hash function.

Sorted hash clusters allow faster retrieval of data for applications where data is
consumed in the order in which it was inserted.

Oracle uses a hash function to generate a distribution of numeric values, called hash
values, which are based on specific cluster key values. The key of a hash cluster, like
the key of an index cluster, can be a single column or composite key (multiple column
key). To find or store a row in a hash cluster, Oracle applies the hash function to the
row’s cluster key value. The resulting hash value corresponds to a data block in the
cluster, which Oracle then reads or writes on behalf of the issued statement.

A hash cluster is an alternative to a nonclustered table with an index or an index
cluster. With an indexed table or index cluster, Oracle locates the rows in a table using
key values that Oracle stores in a separate index. To find or store a row in an indexed
table or cluster, at least two I/Os must be performed:
■ One or more I/Os to find or store the key value in the index
■ Another I/O to read or write the row in the table or cluster

雜湊簇
1. 雜湊簇中,一行資料的儲存位置是依據此行的簇鍵值經過雜湊函式運算所得的結果而決定的。擁有相同簇鍵
值的資料行在磁碟上的儲存在一起。
2. 當一個表的資料經常使用等值條件進行查詢時,以雜湊簇的形式儲存這些資料比在此表上建立索引或索引簇
更適用。Oracle處理查詢時,可以對查詢條件中的簇鍵值進行雜湊運算,運算結果直接指向磁碟中儲存相應資料行
3. 可以建立一個雜湊簇 ,並將表資料載入到此簇中。之後 Oracle 就可以使用雜湊函式的運算結果來訪問數
據了。
4. 如果在一個應用中,查詢資料的順序與這些資料被插入時的順序相同,那麼使用經過排序的雜湊簇能夠提
高資料獲取的速度。
5. Oracle 使用雜湊函式根據簇鍵值生成一個分散式的數值,這個值被稱為雜湊值。雜湊簇使用的鍵同索引簇
的類似,既可以由一列構成,也可以是複合鍵。Oracle 在儲存或查詢雜湊簇中的一行資料時,需要使用此行的簇
鍵值進行雜湊運算。運算結果直接對應著簇中的資料塊內的實體地址,Oracle 就可以依此地址在資料塊內為語句
進行讀或寫操作。
6. 利用非簇表及索引或索引簇儲存的資料,也可以考慮使用雜湊簇儲存。對於使用索引或索引簇的非簇表,
Oracle 利用索引中的鍵值來定位資料行在表中的位置,此時至少需要執行
兩次 I/O 操作:
* 一次或多次 I/O 操作,查詢或儲存索引中的鍵值
* 另一次 I/O 操作,讀寫表或簇中的資料行

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10599713/viewspace-983127/,如需轉載,請註明出處,否則將追究法律責任。

相關文章