During a Hash Table Scan operation, the entire temporary hash table is scanned and all of the entries contained within the hash table will be processed.
The optimizer considers a hash table scan when the data values need to be collated together, but the sequence of the data is not required. The use of a hash table scan will allow the optimizer to generate a plan that can take advantage of any non-join selection while creating the temporary hash table. An additional benefit of using a hash table scan is that the data structure of the temporary hash table will typically cause the table data within the hash table to remain resident within main memory after creation, thus reducing paging on the subsequent hash table scan operation.
Data access method | Hash table scan |
---|---|
Description | Read all of the entries in a temporary hash table. The hash table may perform distinct processing to eliminate duplicates or takes advantage of the temporary hash table to collate all of the rows with the same value together. |
Advantages |
|
Considerations | Generally used for distinct or group by processing. Can perform poorly when the entire hash table does not stay resident in memory as it is being processed. |
Likely to be used |
|
Example SQL statement | SELECT COUNT(*), FirstNme FROM Employee WHERE WorkDept BETWEEN 'A01' AND 'E01' GROUP BY FirstNme |
Messages indicating use | There are multiple ways in which a hash scan can be
indicated through the messages. The messages in this example illustrate how
the SQL Query Engine will indicate a hash scan was used.
|
SMP parallel enabled | Yes |
Also referred to as | Hash Scan, Preload Hash Table Scan Distinct Hash Table Scan Distinct, Preload |
Visual Explain icon |