73 lines
4.0 KiB
HTML
73 lines
4.0 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="Example: Query tool B" />
|
|
<meta name="abstract" content="This example illustrates using one allocation statement for the entire call." />
|
|
<meta name="description" content="This example illustrates using one allocation statement for the entire call." />
|
|
<meta name="DC.Relation" scheme="URI" content="rzaiktoolsbadperf.htm" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 1999, 2006" />
|
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1999, 2006" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="odbcquerytoolb" />
|
|
<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>Example: Query tool B</title>
|
|
</head>
|
|
<body id="odbcquerytoolb"><a name="odbcquerytoolb"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Example: Query tool B</h1>
|
|
<div><p>This example illustrates using one allocation statement for the
|
|
entire call.</p>
|
|
<div class="section"><p>Query tool B allows you to update a spreadsheet of rows and then
|
|
send the updates to the database. It makes the following ODBC calls: </p>
|
|
<pre> FOR every_row_updated DO
|
|
|
|
SQLAllocHandle(SQL_HANDLE_STMT)
|
|
SQLExecDirect("UPDATE...SET COLn='literal'...WHERE COLn='oldval'...")
|
|
SQLFreeHandle( SQL_HANDLE_STMT )
|
|
|
|
END LOOP</pre>
|
|
</div>
|
|
<div class="section"><p>The first thing to note is that the tool performs a statement
|
|
allocation-and-drop for every row. Only one allocate statement is needed.
|
|
This change would save the overhead of creating and destroying a statement
|
|
handle for every operation. Another performance concern is the use of <span class="keyword">SQL</span> with literals instead of with
|
|
parameter markers. The <strong>SQLExecDirect()</strong> call causes an <strong>SQLPrepare</strong> and <strong>SQLExecute</strong> every
|
|
time. A faster way to perform this operation would be as follows: </p>
|
|
<pre> SQLAllocHandle(SQL_HANDLE_STMT)
|
|
SQLPrepare("UPDATE...SET COL1=?...WHERE COL1=?...")
|
|
SQLBindParameter( new_column_buffers )
|
|
SQLBindParameter( old_column_buffers )
|
|
FOR every_row_updated DO
|
|
|
|
...move each rows data into the SQLBindParameter buffers
|
|
SQLExecute()
|
|
SQLFreeHandle( SQL_HANDLE_STMT )
|
|
|
|
END LOOP</pre>
|
|
</div>
|
|
<div class="section"><p>These sets of ODBC calls will outperform the original set by a
|
|
large factor when you are using the <span class="keyword">iSeries™ Access for Windows<sup>®</sup></span> ODBC
|
|
driver. The server CPU utilization will decrease to 10 percent of what it
|
|
was, which pushes the scaling threshold out a lot farther.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzaiktoolsbadperf.htm" title="The following examples demonstrate performance problems that are associated with writing SQL and ODBC calls that do NOT take advantage of a unique feature of a particular ODBC driver or the server database management system.">Examples: Common tool behaviors that degrade ODBC performance</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |