ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzajq_5.4.0.1/gotips.htm

77 lines
4.6 KiB
HTML
Raw Permalink 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="General query optimization tips" />
<meta name="abstract" content="Here are some tips to help your queries run as fast as possible." />
<meta name="description" content="Here are some tips to help your queries run as fast as possible." />
<meta name="DC.Relation" scheme="URI" content="per0001.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/rgzpfm.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/chgpf.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="gotips" />
<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>General query optimization tips</title>
</head>
<body id="gotips"><a name="gotips"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">General query optimization tips</h1>
<div><p>Here are some tips to help your queries run as fast as possible.</p>
<div class="section"> <ul><li>Create indexes whose leftmost key columns match your selection predicates
to help supply the optimizer with selectivity values (key range estimates).</li>
<li>For join queries, create indexes that match your join columns to help
the optimizer determine the average number of matching rows.</li>
<li>Minimize extraneous mapping by specifying only columns of interest on
the query. For example, specify only the columns you need to query on the
SQL SELECT statement instead of specifying SELECT *. Also, you should specify
FOR FETCH ONLY if the columns do not need to be updated.</li>
<li>If your queries often use table scan access method, use the <span class="cmdname">Reorganize
Physical File Member (RGZPFM)</span> command to remove deleted rows from
tables or the <span class="cmdname">Change Physical File (CHGPF)</span> REUSEDLT (*YES)
command to reuse deleted rows.</li>
</ul>
</div>
<div class="section"><p>Consider using the following options:</p>
</div>
<div class="section"> <ul><li>Specify ALWCPYDTA(*OPTIMIZE) to allow the query optimizer to create temporary
copies of data so better performance can be obtained. The iSeries™ Access
ODBC driver and Query Management driver always uses this mode. If ALWCPYDTA(*YES)
is specified, the query optimizer will attempt to implement the query without
copies of the data, but may create copies if required. If ALWCPYDTA(*NO)
is specified, copies of the data are not allowed. If the query optimizer
cannot find a plan that does not use a temporary, then the query cannot be
run. </li>
<li>For SQL, use CLOSQLCSR(*ENDJOB) or CLOSQLCSR(*ENDACTGRP) to allow open
data paths to remain open for future invocations.</li>
<li>Specify DLYPRP(*YES) to delay SQL statement validation until an OPEN,
EXECUTE, or DESCRIBE statement is run. This option improves performance by
eliminating redundant validation.</li>
<li>Use ALWBLK(*ALLREAD) to allow row blocking for read-only cursors.</li>
</ul>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="per0001.htm" title="This overview of the query optimizer provides guidelines for designing queries that will perform and will use server resources more efficiently.">Processing queries: Overview</a></div>
</div>
<div class="relinfo"><strong>Related information</strong><br />
<div><a href="../cl/rgzpfm.htm">Reorganize Physical File Member (RGZPFM) command</a></div>
<div><a href="../cl/chgpf.htm">Change Physical File (CHGPF) command</a></div>
</div>
</div>
</body>
</html>