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

140 lines
8.3 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="Collocated join with DB2 Multisystem" />
<meta name="abstract" content="In a collocated join, corresponding records of files being joined exist on the same node." />
<meta name="description" content="In a collocated join, corresponding records of files being joined exist on the same node." />
<meta name="DC.subject" content="query, collocated join, join, collocated, example, collocated join query" />
<meta name="keywords" content="query, collocated join, join, collocated, example, collocated join query" />
<meta name="DC.Relation" scheme="URI" content="joins.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="collocated" />
<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>Collocated join with DB2 Multisystem</title>
</head>
<body id="collocated"><a name="collocated"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Collocated join with DB2<sup>®</sup> Multisystem</h1>
<div><p>In a collocated join, corresponding records of files being joined
exist on the same node.</p>
<div class="section"><p>The values of the partitioning key of the files being joined are
partition compatible. No data needs to be moved to another node to perform
the join. This method is only valid for queries where all of the fields of
the partitioning keys are join fields and the join operator is the = (equals)
operator. Also, the nth field (where n=1 to the number of fields in the partitioning
key) of the partitioning key of the first file must be joined to the nth field
of the partitioning key of the second file, and the data types of the nth
fields must be partition compatible. Note that all of the fields of the partitioning
key must be involved in the join. Additional join predicates that do not contain
fields of the partitioning key do not affect your ability to do a collocated
join.</p>
<p>In the following example, because the join predicate involves
the partitioning key fields of both files and the fields are partition compatible,
a collocated join can be performed. This implies that matching values of DEPTNO
and WORKDEPT are located on the same node.</p>
<p>SQL statement:</p>
<pre> SELECT DEPTNAME, FIRSTNME, LASTNAME
FROM DEPARTMENT, EMPLOYEE
WHERE DEPTNO=WORKDEPT</pre>
<p>OPNQRYF command:</p>
<pre> OPNQRYF FILE((DEPARTMENT) (EMPLOYEE))
FORMAT(JOINFMT)
JFLD((DEPTNO WORKDEPT *EQ))</pre>
<p>Records returned
by this query:</p>
<table cellpadding="4" cellspacing="0" border="1" class="tableborder"><tr><td>
<table cellpadding="4" cellspacing="0" summary="" border="0"><caption>Table 1. Display of the query results</caption><thead align="left"><tr><th align="left" valign="bottom" width="33.33333333333333%" id="d0e75">DEPTNAME</th>
<th align="left" valign="bottom" width="33.33333333333333%" id="d0e77">FIRSTNME</th>
<th align="left" valign="bottom" width="33.33333333333333%" id="d0e79">LASTNAME</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e75 ">Support services</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e77 ">Christine</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e79 ">Haas</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e75 ">Support services</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e77 ">Sally</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e79 ">Kwan</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e75 ">Planning</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e77 ">John</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e79 ">Geyer</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e75 ">Planning</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e77 ">Irving</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e79 ">Stern</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e75 ">Accounting</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e77 ">Michael</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e79 ">Thompson</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e75 ">Accounting</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e77 ">Eileen</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e79 ">Henderson</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e75 ">Programming</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e77 ">Jennifer</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e79 ">Lutz</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e75 ">Programming</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e77 ">David</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e79 ">White</td>
</tr>
</tbody>
</table>
</td></tr></table>
<div class="p">In the following example, the additional join predicate MGRNO=EMPNO
does not affect the ability to perform a collocated join, because the partitioning
keys are still involved in a join predicate. <pre>SQL: SELECT DEPTNAME, FIRSTNME, LASTNAME
FROM DEPARTMENT, EMPLOYEE
WHERE DEPTNO=WORKDEPT AND MGRNO=EMPNO</pre>
<pre>OPNQRYF: OPNQRYF FILE((DEPARTMENT) (EMPLOYEE))
FORMAT(JOINFMT)
JFLD((DEPTNO WORKDEPT *EQ) (MGRNO EMPNO *EQ))</pre>
</div>
<p>Records
returned by this query:</p>
<table cellpadding="4" cellspacing="0" border="1" class="tableborder"><tr><td>
<table cellpadding="4" cellspacing="0" summary="" border="0"><caption>Table 2. Display of the query
results</caption><thead align="left"><tr><th align="left" valign="bottom" width="33.33333333333333%" id="d0e155">DEPTNAME</th>
<th align="left" valign="bottom" width="33.33333333333333%" id="d0e157">FIRSTNME</th>
<th align="left" valign="bottom" width="33.33333333333333%" id="d0e159">LASTNAME</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e155 ">Support services</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e157 ">Christine</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e159 ">Haas</td>
</tr>
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e155 ">Accounting</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e157 ">Michael</td>
<td align="left" valign="top" width="33.33333333333333%" headers="d0e159 ">Thompson</td>
</tr>
</tbody>
</table>
</td></tr></table>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="joins.htm" title="In addition to the performance considerations for nondistributed join queries, more performance considerations exist for queries involving distributed files.">Implementation and optimization of join operations with DB2 Multisystem</a></div>
</div>
</div>
</body>
</html>