73 lines
5.9 KiB
HTML
73 lines
5.9 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="Tips for improving performance when selecting data from more than two tables" />
|
|
<meta name="abstract" content="The following suggestion is only applicable to CQE and is directed specifically to select-statements that access several tables. For joins that involve more than two tables, you might want to provide redundant information about the join columns. The CQE optimizer does not generate transitive closure predicates between 2 columns. If you give the optimizer extra information to work with when requesting a join, it can determine the best way to do the join. The additional information might seem redundant, but is helpful to the optimizer." />
|
|
<meta name="description" content="The following suggestion is only applicable to CQE and is directed specifically to select-statements that access several tables. For joins that involve more than two tables, you might want to provide redundant information about the join columns. The CQE optimizer does not generate transitive closure predicates between 2 columns. If you give the optimizer extra information to work with when requesting a join, it can determine the best way to do the join. The additional information might seem redundant, but is helpful to the optimizer." />
|
|
<meta name="DC.subject" content="improving performance, selecting data from multiple tables, selecting, data from multiple tables, performance improvement, selecting data from multiple tables, data, selecting from multiple tables, affect on performance, multiple, table, improving performance when selecting data from, improving performance when selecting data from, examples" />
|
|
<meta name="keywords" content="improving performance, selecting data from multiple tables, selecting, data from multiple tables, performance improvement, selecting data from multiple tables, data, selecting from multiple tables, affect on performance, multiple, table, improving performance when selecting data from, improving performance when selecting data from, examples" />
|
|
<meta name="DC.Relation" scheme="URI" content="perf24.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="rzajqtipsdata" />
|
|
<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>Tips for improving performance when selecting data from more than two
|
|
tables</title>
|
|
</head>
|
|
<body id="rzajqtipsdata"><a name="rzajqtipsdata"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Tips for improving performance when selecting data from more than two
|
|
tables</h1>
|
|
<div><p>The following suggestion is only applicable to CQE and is directed
|
|
specifically to select-statements that access several tables. For joins that
|
|
involve more than two tables, you might want to provide redundant information
|
|
about the join columns. The CQE optimizer does not generate transitive closure
|
|
predicates between 2 columns. If you give the optimizer extra information
|
|
to work with when requesting a join, it can determine the best way to do the
|
|
join. The additional information might seem redundant, but is helpful to
|
|
the optimizer.</p>
|
|
<div class="section"><p>If the select-statement you are considering accesses two or more
|
|
tables, all the recommendations suggested in <a href="efindex.htm#efindex">Creating an index strategy</a> apply.
|
|
For example, instead of coding:</p>
|
|
<pre> EXEC SQL
|
|
<strong>DECLARE</strong> EMPACTDATA <strong>CURSOR FOR</strong>
|
|
<strong>SELECT</strong> LASTNAME, DEPTNAME, PROJNO, ACTNO
|
|
<strong>FROM</strong> CORPDATA.DEPARTMENT, CORPDATA.EMPLOYEE,
|
|
CORPDATA.EMP_ACT
|
|
<strong>WHERE</strong> DEPARTMENT.MGRNO = EMPLOYEE.EMPNO
|
|
<strong>AND</strong> EMPLOYEE.EMPNO = EMP_ACT.EMPNO
|
|
END-EXEC.</pre>
|
|
</div>
|
|
<div class="section"><p>Provide the optimizer with a little more data and code: </p>
|
|
<pre> EXEC SQL
|
|
<strong>DECLARE</strong> EMPACTDATA <strong>CURSOR FOR</strong>
|
|
<strong>SELECT</strong> LASTNAME, DEPTNAME, PROJNO, ACTNO
|
|
<strong>FROM</strong> CORPDATA.DEPARTMENT, CORPDATA.EMPLOYEE,
|
|
CORPDATA.EMP_ACT
|
|
<strong>WHERE</strong> DEPARTMENT.MGRNO = EMPLOYEE.EMPNO
|
|
<strong>AND</strong> EMPLOYEE.EMPNO = EMP_ACT.EMPNO
|
|
<strong>AND</strong> DEPARTMENT.MGRNO = EMP_ACT.EMPNO
|
|
END-EXEC.</pre>
|
|
</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>
|
|
</body>
|
|
</html> |