ibm-information-center/dist/eclipse/plugins/i5OS.ic.dbmult_5.4.0.1/twostep.htm

74 lines
4.3 KiB
HTML

<?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="Two-step grouping with DB2 Multisystem" />
<meta name="abstract" content="If the partitioning key is not included in the grouping fields, then grouping must be done using two-step grouping, because the like values of a field are not located on the same node." />
<meta name="description" content="If the partitioning key is not included in the grouping fields, then grouping must be done using two-step grouping, because the like values of a field are not located on the same node." />
<meta name="DC.subject" content="grouping, two-step, optimization, two-step grouping" />
<meta name="keywords" content="grouping, two-step, optimization, two-step grouping" />
<meta name="DC.Relation" scheme="URI" content="grouping.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="twostep" />
<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>Two-step grouping with DB2 Multisystem</title>
</head>
<body id="twostep"><a name="twostep"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Two-step grouping with DB2<sup>®</sup> Multisystem</h1>
<div><p>If the partitioning key is not included in the grouping fields,
then grouping must be done using two-step grouping, because the like values
of a field are not located on the same node.</p>
<div class="section"><p>The following code is an example of two-step grouping.
</p>
<p>SQL statement:</p>
<pre> SELECT JOB, AVG(SALARY)
FROM EMPLOYEE
GROUP BY JOB
</pre>
<p>OPNQRYF command:</p>
<pre> OPNQRYF FILE((EMPLOYEE)) FORMAT(GRPFMT2)
GRPFLD(JOB)
MAPFLD((AVGSAL '%AVG(SALARY)'))</pre>
<p>In this example, note that for the group where JOB is <tt>Clerk</tt>,
the value <tt>Clerk</tt> is on two different nodes in the EMPLOYEE distributed
file. Grouping is implemented by first running grouping in parallel on all
three nodes. This results in an initial grouping which is placed in a temporary
file at the coordinator node. The query is modified, and the grouping is run
again at the coordinator node to get the final set of grouping results.</p>
<p>Whole-file
grouping (no group by fields) is always implemented using two steps.</p>
<p>If
the query contains either a HAVING clause or the group selection expression
(GRPSLT) parameter on the OPNQRYF command, all groups from the first grouping
step are returned to the coordinator node. The HAVING clause or the GRPSLT
parameter is then processed as part of second grouping step.</p>
<p>If the
query contains a DISTINCT column (aggregate) function and two-step grouping
is required, no grouping is done in the first step. Instead, all records are
returned to the coordinator node, and all grouping is run at the coordinator
node as part of the second step.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="grouping.htm" title="The implementation method for grouping in queries that use distributed files is dependent on whether the partitioning key is included in the grouping criteria.">Implementation and optimization of grouping with DB2 Multisystem</a></div>
</div>
</div>
</body>
</html>