ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzajq_5.4.0.1/rzajqhtblscan.htm

119 lines
7.0 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Hash table scan" />
<meta name="abstract" content="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." />
<meta name="description" content="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." />
<meta name="DC.subject" content="definitions, hash table scan access method, hash table, scan access method, access method, hash table scan" />
<meta name="keywords" content="definitions, hash table scan access method, hash table, scan access method, access method, hash table scan" />
<meta name="DC.Relation" scheme="URI" content="rzajqtemphash.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzajqhtblscan" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Hash table scan</title>
</head>
<body id="rzajqhtblscan"><a name="rzajqhtblscan"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Hash table scan</h1>
<div><p>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.</p>
<div class="section"><p>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.</p>
</div>
<div class="section">
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="border" border="1" rules="all"><caption>Table 1. Hash table scan attributes</caption><thead align="left"><tr><th valign="top" width="30.96446700507614%" id="d0e37">Data access method</th>
<th valign="top" width="69.03553299492386%" id="d0e39">Hash table scan</th>
</tr>
</thead>
<tbody><tr><td valign="top" width="30.96446700507614%" headers="d0e37 "><strong>Description</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e39 "> 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.</td>
</tr>
<tr><td valign="top" width="30.96446700507614%" headers="d0e37 "><strong>Advantages</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e39 "><ul><li>Reduces the random I/O to the table generally associated with longer running
queries that may otherwise use an index to collate the data</li>
<li>Selection can be performed before generating the hash table to subset
the number of rows in the temporary object</li>
</ul>
</td>
</tr>
<tr><td valign="top" width="30.96446700507614%" headers="d0e37 "><strong>Considerations</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e39 ">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.</td>
</tr>
<tr><td valign="top" width="30.96446700507614%" headers="d0e37 "><strong>Likely to be used</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e39 "><ul><li>When the use of temporary results is allowed by the query environmental
parameter (ALWCPYDTA)</li>
<li>When the data is required to be collated based upon a column or columns
for distinct or grouping</li>
</ul>
</td>
</tr>
<tr><td valign="top" width="30.96446700507614%" headers="d0e37 "><strong>Example SQL statement</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e39 "><pre>SELECT COUNT(*), FirstNme FROM Employee
WHERE WorkDept BETWEEN 'A01' AND 'E01'
GROUP BY FirstNme</pre>
</td>
</tr>
<tr><td valign="top" width="30.96446700507614%" headers="d0e37 "><strong>Messages indicating use</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e39 ">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. <ul><li>Optimizer Debug: <pre>CPI4329 -- Arrival sequence was used for file
EMPLOYEE.</pre>
</li>
<li>PRTSQLINF: <pre>SQL4010 -- Table scan access for table 1.
SQL4029 -- Hashing algorithm used to process
the grouping.</pre>
</li>
</ul>
</td>
</tr>
<tr><td valign="top" width="30.96446700507614%" headers="d0e37 "><strong>SMP parallel enabled</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e39 ">Yes</td>
</tr>
<tr><td valign="top" width="30.96446700507614%" headers="d0e37 "><strong>Also referred to as</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e39 ">Hash Scan, Preload <p>Hash Table Scan Distinct</p>
<p>Hash
Table Scan Distinct, Preload</p>
</td>
</tr>
<tr><td valign="top" width="30.96446700507614%" headers="d0e37 "><strong>Visual Explain icon</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e39 "><br /><img src="rzajq513.gif" alt="Hash table scan icon" /><br /></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajqtemphash.htm" title="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.">Temporary hash table</a></div>
</div>
</div>
</body>
</html>