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

103 lines
6.2 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="Temporary result writer with DB2 Multisystem" />
<meta name="abstract" content="Temporary result writers are system-initiated jobs that are always active." />
<meta name="description" content="Temporary result writers are system-initiated jobs that are always active." />
<meta name="DC.subject" content="temporary result writer, temporary result writer, writer, temporary result, writer, temp" />
<meta name="keywords" content="temporary result writer, temporary result writer, writer, temporary result, writer, temp" />
<meta name="DC.Relation" scheme="URI" content="qqp.htm" />
<meta name="DC.Relation" scheme="URI" content="tempad.htm" />
<meta name="DC.Relation" scheme="URI" content="tempdisad.htm" />
<meta name="DC.Relation" scheme="URI" content="tempcontrol.htm" />
<meta name="DC.Relation" scheme="URI" content="chgqrya.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="tempresult" />
<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>Temporary result writer with DB2 Multisystem</title>
</head>
<body id="tempresult"><a name="tempresult"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Temporary result writer with DB2<sup>®</sup> Multisystem</h1>
<div><p>Temporary result writers are system-initiated jobs that are always
active.</p>
<div class="section"><p>On the system, temporary result writers are paired jobs called
QQQTEMP1 and QQQTEMP2. Temporary result writers handle requests from jobs
that are running queries. These requests consist of a query (of the query
step) to run and the name of a system temporary file to fill from the results
of the query. The temporary result writer processes the request and fills
the temporary file. This intermediate temporary file is then used by the requesting
job to complete the original query.</p>
<p>The following example shows a query
that requires a temporary result writer and the steps needed to process the
query. </p>
<p>SQL statement:</p>
<pre>SELECT COUNT(*)
FROM DEPARTMENT a, EMPLOYEE b
WHERE a.ADMRDEPT = b.WORKDEPT
AND b.JOB = 'Manager'
</pre>
<p>OPNQRYF command:</p>
<pre> OPNQRYF FILE((DEPARTMENT) (EMPLOYEE))
FORMAT(FMTFILE)
MAPFLD((CNTFLD '%COUNT'))
JFLD((1/ADMRDEPT 2/WORKDEPT))
QRYSLT('2/JOB = 'Manager')</pre>
<div class="p">WORKDEPT
is the partitioning key for EMPLOYEE, but ADMRDEPT is not the partitioning
key for DEPARTMENT. Because the query must be processed in two steps, the
optimizer splits the query into the following steps: <pre> INSERT INTO SYS_TEMP_FILE
SELECT a.DEPTNAME, a.ADMRDEPT
FROM DEPARTMENT a</pre>
</div>
<div class="p">and <pre> SELECT COUNT(*) FROM SYS_TEMP_FILE x, EMPLOYEE b
WHERE x.ADMRDEPT = b.WORKDEPT AND b.JOB = 'Manager'</pre>
</div>
<p>If a temporary result writer is
allowed for the job (controlled by the Change Query Attributes (CHGQRYA) options),
the optimizer:</p>
<ol><li>Creates the temporary file (SYS_TEMP_FILE) into library QRECOVERY.</li>
<li>Sends the request that populates SYS_TEMP_FILE to the temporary result
writer.</li>
<li>Continues to finish opening the final query (while the temporary result
writer is filling the temporary file).</li>
<li>After the final query is opened, waits until the temporary
result writer has finished filling the temporary file before returning control
to its caller.</li>
</ol>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="tempad.htm">Temporary result writer job: Advantages with DB2 Multisystem</a></strong><br />
The advantage of using a temporary result writer job in processing a request is that the temporary result writer can process its request at the same time (in parallel) that the main job is processing another step of the query.</li>
<li class="ulchildlink"><strong><a href="tempdisad.htm">Temporary result writer job: Disadvantages with DB2 Multisystem</a></strong><br />
The temporary result writer also has disadvantages that must be considered when you determine its usefulness for queries.</li>
<li class="ulchildlink"><strong><a href="tempcontrol.htm">Control of the temporary result writer with DB2 Multisystem</a></strong><br />
By default, queries do not use the temporary result writer. Temporary result writer usage, however, can be enabled by using the Change Query Attributes (CHGQRYA) command.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="qqp.htm" title="This topic provides you with some guidelines for designing queries so that they use query resources more efficiently when you run queries that use distributed files.">Query design for performance with DB2 Multisystem</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="chgqrya.htm" title="The CHGQRYA command has two parameters that are applicable to distributed queries.">Changes to the change query attributes (CHGQRYA) command with DB2 Multisystem</a></div>
</div>
</div>
</body>
</html>