Temporary hash table

 

The temporary hash table is a temporary object that allows the optimizer to collate the rows based upon a column or set of columns. The hash table can be either scanned or probed by the optimizer to satisfy different operations of the query.

A temporary hash table is an efficient data structure because the rows are organized for quick and easy retrieval after population has occurred. This is primarily due to the hash table remaining resident within main memory so as to avoid any I/Os associated with either the scan or probe against the temporary object. The optimizer will determine the optimal size for the hash table based upon the number of unique combinations (for example, cardinality) of the columns used as keys for the creation.

Additionally the hash table can be populated with all of the necessary columns to satisfy any further processing, avoiding any random I/Os associated with a Table Probe operation. However, the optimizer does have the ability to selectively include columns in the hash table when the calculated size will exceed the memory pool storage available for this query. In those cases, a Table Probe operation is required to recollect the missing columns from the hash table before the selected rows can be processed.

The optimizer also has the ability to populate the hash table with distinct values. If the query contains grouping or distinct processing, then all of the rows with the same key value are not required to be stored in the temporary object. They are still collated, but the distinct processing is performed during the population of the hash table itself. This allows a simple scan to be performed on the result in order to complete the grouping or distinct operation.

A temporary hash table is an internal data structure and can only be created by the database manager

Visual explain icon:

Temporary hash table icon

 

Parent topic:

Temporary objects and access methods