67 lines
5.3 KiB
HTML
67 lines
5.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="concept" />
|
||
|
<meta name="DC.Title" content="Coding for effective indexes" />
|
||
|
<meta name="abstract" content="The following topics provide suggestions that will help you to design code which allows DB2 Universal Database for iSeries to take advantage of available indexes:" />
|
||
|
<meta name="description" content="The following topics provide suggestions that will help you to design code which allows DB2 Universal Database for iSeries to take advantage of available indexes:" />
|
||
|
<meta name="DC.subject" content="index, coding for effective indexes" />
|
||
|
<meta name="keywords" content="index, coding for effective indexes" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="efindex.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="avoidnumconv.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="avoidarithexp.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="avoidcharpad.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="avoidpatterns.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="rzajqeffectindex" />
|
||
|
<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>Coding for effective indexes</title>
|
||
|
</head>
|
||
|
<body id="rzajqeffectindex"><a name="rzajqeffectindex"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Coding for effective indexes</h1>
|
||
|
<div><p>The following topics provide suggestions that will help you to
|
||
|
design code which allows <span class="keyword">DB2 Universal Database™ for iSeries™</span> to
|
||
|
take advantage of available indexes: </p>
|
||
|
</div>
|
||
|
<div>
|
||
|
<ul class="ullinks">
|
||
|
<li class="ulchildlink"><strong><a href="avoidnumconv.htm">Avoid numeric conversions</a></strong><br />
|
||
|
When a column value and a host variable (or constant value) are
|
||
|
being compared, try to specify the same data types and attributes. <span class="keyword">DB2 Universal Database for iSeries</span> does not use an index for
|
||
|
the named column if the host variable or constant value has a greater precision
|
||
|
than the precision of the column. If the two items being compared have different
|
||
|
data types, <span class="keyword">DB2 Universal Database for iSeries</span> will
|
||
|
need to convert one or the other of the values, which can result in inaccuracies
|
||
|
(because of limited machine precision).</li>
|
||
|
<li class="ulchildlink"><strong><a href="avoidarithexp.htm">Avoid arithmetic expressions</a></strong><br />
|
||
|
Do not use an arithmetic expression as an operand to be compared to a column in a row selection predicate. The optimizer does not use an index on a column that is being compared to an arithmetic expression. While this may not cause an index over the column to become unusable, it will prevent any estimates and possibly the use of index scan-key positioning on the index. The primary thing that is lost is the ability to use and extract any statistics that might be useful in the optimization of the query.</li>
|
||
|
<li class="ulchildlink"><strong><a href="avoidcharpad.htm">Avoid character string padding</a></strong><br />
|
||
|
Try to use the same data length when comparing a fixed-length character
|
||
|
string column value to a host variable or constant value. <span class="keyword">DB2 Universal Database for iSeries</span> does
|
||
|
not use an index if the constant value or host variable is longer than the
|
||
|
column length.</li>
|
||
|
<li class="ulchildlink"><strong><a href="avoidpatterns.htm">Avoid the use of like patterns beginning with % or _</a></strong><br />
|
||
|
The percent sign (%), and the underline (_), when used in the pattern of a LIKE (OPNQRYF %WLDCRD) predicate, specify a character string that is similar to the column value of rows you want to select. They can take advantage of indexes when used to denote characters in the middle or at the end of a character string.</li>
|
||
|
</ul>
|
||
|
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="efindex.htm" title="DB2 Universal Database for iSeries provides two basic means for accessing tables: a table scan and an index-based retrieval. Index-based retrieval is typically more efficient than table scan when less than 20% of the table rows are selected.">Creating an index strategy</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|