100 lines
6.8 KiB
HTML
100 lines
6.8 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="Cost estimation and index selection for join secondary dials" />
|
|
<meta name="abstract" content="As the query optimizer compares the various possible access choices, it must assign a numeric cost value to each candidate and use that value to determine the implementation which consumes the least amount of processing time. This costing value is a combination of CPU and I/O time" />
|
|
<meta name="description" content="As the query optimizer compares the various possible access choices, it must assign a numeric cost value to each candidate and use that value to determine the implementation which consumes the least amount of processing time. This costing value is a combination of CPU and I/O time" />
|
|
<meta name="DC.Relation" scheme="URI" content="perf24.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../cl/setobjacc.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="costselect" />
|
|
<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>Cost estimation and index selection for join secondary dials</title>
|
|
</head>
|
|
<body id="costselect"><a name="costselect"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Cost estimation and index selection for join secondary dials</h1>
|
|
<div><p>As the query optimizer compares the various possible access choices,
|
|
it must assign a numeric cost value to each candidate and use that value to
|
|
determine the implementation which consumes the least amount of processing
|
|
time. This costing value is a combination of CPU and I/O time</p>
|
|
<div class="section"><p>In step 3 and in step 5 in <a href="rzajqjoinorder.htm">Join order optimization</a>,
|
|
the query optimizer has to estimate a cost and choose an access method for
|
|
a given dial combination. The choices made are similar to those for row selection
|
|
except that a plan using a probe must be chosen.</p>
|
|
</div>
|
|
<div class="section"><div class="p">The costing value is based on the following assumptions: <ul><li>Table pages and index pages must be retrieved from auxiliary storage.
|
|
For example, the query optimizer is not aware that an entire table may be
|
|
loaded into active memory as the result of a <span class="cmdname">Set Object
|
|
Access (SETOBJACC)</span> CL command. Usage of this command may significantly
|
|
improve the performance of a query, but the query optimizer does not change
|
|
the query implementation to take advantage of the memory resident state of
|
|
the table.</li>
|
|
<li>The query is the only process running on the server. No allowance is given
|
|
for server CPU utilization or I/O waits which occur because of other processes
|
|
using the same resources. CPU related costs are scaled to the relative processing
|
|
speed of the server running the query.</li>
|
|
<li>The values in a column are uniformly distributed across the table. For
|
|
example, if 10% of the rows in a table have the same value, then it is assumed
|
|
that every tenth row in the table contains that value.</li>
|
|
<li>The values in a column are independent from the values in any other columns
|
|
in a row, unless there is an index available whose key definition is (A,B).
|
|
Multi key field indexes allows the optimizer to detect when the values between
|
|
columns are correlated. For example, if a column named <samp class="codeph">A</samp> has
|
|
a value of <samp class="codeph">1</samp> in 50% of the rows in a table and a column named <samp class="codeph">B</samp> has
|
|
a value of <samp class="codeph">2</samp> in 50% of the rows, then it is expected that
|
|
a query which selects rows where <samp class="codeph">A = 1</samp>, and <samp class="codeph">B = 2</samp> selects
|
|
25% of the rows in the table.</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="section"><p>The main factors of the join cost calculations for secondary dials
|
|
are the number of rows selected in all previous dials and the number of rows
|
|
which match, on average, each of the rows selected from previous dials. Both
|
|
of these factors can be derived by estimating the number of matching rows
|
|
for a given dial.</p>
|
|
</div>
|
|
<div class="section"><div class="p">When the join operator is something other than equal, the expected
|
|
number of matching rows is based on the following default filter factors:
|
|
<ul><li>33% for less-than, greater-than, less-than-equal-to, or greater-than-equal-to</li>
|
|
<li>90% for not equal</li>
|
|
<li>25% for BETWEEN range (OPNQRYF %RANGE)</li>
|
|
<li>10% for each IN list value (OPNQRYF %VALUES)</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="section"><p>For example, when the join operator is less-than, the expected
|
|
number of matching rows is .33 * (number of rows in the dial). If no join
|
|
specifications are active for the current dial, the cartesian product is assumed
|
|
to be the operator. For cartesian products, the number of matching rows is
|
|
every row in the dial, unless local row selection can be applied to the index.</p>
|
|
</div>
|
|
<div class="section"><p id="costselect__ixdup"><a name="costselect__ixdup"><!-- --></a>When the join operator is equal, the expected number
|
|
of rows is the average number of duplicate rows for a given value.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="perf24.htm" title="A join operation is a complex function that requires special attention in order to achieve good performance. This section describes how DB2 Universal Database for iSeries implements join queries and how optimization choices are made by the query optimizer. It also describes design tips and techniques which help avoid or solve performance problems.">Join optimization</a></div>
|
|
</div>
|
|
<div class="relinfo"><strong>Related information</strong><br />
|
|
<div><a href="../cl/setobjacc.htm">Set Object Access (SETOBJACC) command</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |