87 lines
5.9 KiB
HTML
87 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="Use FETCH FOR n ROWS" />
|
|
<meta name="abstract" content="Applications that perform many FETCH statements in succession may be improved by using FETCH FOR n ROWS. With this clause, you can retrieve multiple rows of data from a table and put them into a host structure array or row storage area with a single FETCH." />
|
|
<meta name="description" content="Applications that perform many FETCH statements in succession may be improved by using FETCH FOR n ROWS. With this clause, you can retrieve multiple rows of data from a table and put them into a host structure array or row storage area with a single FETCH." />
|
|
<meta name="DC.subject" content="improving performance, using, FETCH FOR n ROWS, statements, FETCH, FOR n ROWS, calls, number, FETCH statement, number of calls, using a FETCH statement, number of calls" />
|
|
<meta name="keywords" content="improving performance, using, FETCH FOR n ROWS, statements, FETCH, FOR n ROWS, calls, number, FETCH statement, number of calls, using a FETCH statement, number of calls" />
|
|
<meta name="DC.Relation" scheme="URI" content="progtech.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="improvesqlblock.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../db2/rbafzmstfets.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="fetchnrows" />
|
|
<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>Use FETCH FOR n ROWS</title>
|
|
</head>
|
|
<body id="fetchnrows"><a name="fetchnrows"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Use FETCH FOR n ROWS</h1>
|
|
<div><p>Applications that perform many FETCH statements in succession may
|
|
be improved by using FETCH FOR n ROWS. With this clause, you can retrieve
|
|
multiple rows of data from a table and put them into a host structure array
|
|
or row storage area with a single FETCH.</p>
|
|
<div class="section"><p>An SQL application that uses a FETCH statement without the FOR
|
|
n ROWS clause can be improved by using the multiple-row FETCH statement to
|
|
retrieve multiple rows. After the host structure array or row
|
|
storage area has been filled by the FETCH, the application can loop through
|
|
the data in the array or storage area to process each of the individual rows.
|
|
The statement runs faster because the SQL run-time was called only once and
|
|
all the data was simultaneously returned to the application program.</p>
|
|
</div>
|
|
<div class="section"><p>You can change the application program to allow the database manager
|
|
to block the rows that the SQL run-time retrieves from the tables.</p>
|
|
</div>
|
|
<div class="section"><p>In the following table, the program attempted to FETCH 100 rows
|
|
into the application. Note the differences in the table for the number of
|
|
calls to SQL run-time and the database manager when blocking can be performed.</p>
|
|
</div>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="hsides" border="1" rules="all"><caption>Table 1. Number of Calls Using a FETCH
|
|
Statement</caption><thead align="left"><tr valign="bottom"><th valign="bottom" width="33.33333333333333%" id="d0e66"> </th>
|
|
<th valign="bottom" width="33.33333333333333%" id="d0e67">Database Manager Not Using Blocking</th>
|
|
<th valign="bottom" width="33.33333333333333%" id="d0e69">Database Manager Using Blocking</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e66 ">Single-Row FETCH Statement</td>
|
|
<td align="left" valign="top" width="33.33333333333333%" headers="d0e67 ">100 SQL calls 100 database calls</td>
|
|
<td align="left" valign="top" width="33.33333333333333%" headers="d0e69 ">100 SQL calls 1 database call</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="33.33333333333333%" headers="d0e66 ">Multiple-Row FETCH Statement</td>
|
|
<td align="left" valign="top" width="33.33333333333333%" headers="d0e67 ">1 SQL run-time call 100 database calls</td>
|
|
<td align="left" valign="top" width="33.33333333333333%" headers="d0e69 ">1 SQL run-time call 1 database call</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<ul class="ullinks">
|
|
<li class="ulchildlink"><strong><a href="improvesqlblock.htm">Improve SQL blocking performance when using FETCH FOR n ROWS</a></strong><br />
|
|
Special performance considerations should be made for the following points when using FETCH FOR n ROWS.</li>
|
|
</ul>
|
|
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="progtech.htm" title="By changing the coding of your queries, you can improve their performance.">Programming techniques for database performance</a></div>
|
|
</div>
|
|
<div class="relinfo"><strong>Related information</strong><br />
|
|
<div><a href="../db2/rbafzmstfets.htm">FETCH statement</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |