13.01.2013 Views

OpenEdge Data Management: DataServer for Microsoft SQL Server

OpenEdge Data Management: DataServer for Microsoft SQL Server

OpenEdge Data Management: DataServer for Microsoft SQL Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 2: Initial Programming Considerations<br />

Impact of MAX-ROWS<br />

The MAX-ROWS qualifier on a query determines the number of rows returned. The<br />

MAX-ROWS calculation is applied be<strong>for</strong>e any sorting is applied to the query, causing the<br />

results to be random. Consider the following example:<br />

DEFINE QUERY x FOR customer SCROLLING.<br />

OPEN QUERY x FOR EACH customer MAX-R0WS 15.<br />

GET LAST x.<br />

DISPLAY customer.custnum.<br />

REPEAT:<br />

GET PREV x.<br />

DISPLAY customer.custnum.<br />

END.<br />

When this example is run with the <strong>OpenEdge</strong> sports database, the first record return<br />

has custnum 54, and the repeat loop displays other custnums in descending order from<br />

there. When this example is run with the sports database migrated to MS <strong>SQL</strong> <strong>Server</strong>,<br />

the first record returned has custnum 15, and the repeat loop displays values in<br />

descending order from there. This difference in results is a caused by the MAX-ROWS<br />

being applied prior to the sorting.<br />

Block cursors<br />

Block cursors are available as a per<strong>for</strong>mance enhancement. They allow blocks of<br />

records to be bound and fetched together from a single database request, thus<br />

reducing the network overhead and minimizing record copies <strong>for</strong> ABL queries and<br />

finds, and minimizing record copies.<br />

Considering block cursors and firehose cursors<br />

Block cursors are the default behavior replacing look-ahead cursors <strong>for</strong> NO-LOCK<br />

queries that are processed on the server side. A NO-LOCK query is one that executes<br />

with the NO-LOCK lock condition attached to its ABL statement.<br />

Block cursors are the preferred choice to process NO-LOCK queries on the server side.<br />

However, server-side cursor processing is not the primary choice overall. Firehose<br />

cursors, providing optimum per<strong>for</strong>mance <strong>for</strong> NO-LOCK queries, surpasses the benefits<br />

of block cursors because they are client-based. For an in depth presentation of firehose<br />

cursors, see the “Firehose and Fast Forward-Only Cursors” section on page 164.<br />

Additional details about block cursor behavior<br />

<strong>Data</strong><strong>Server</strong> connections that run at the read uncommitted isolation level will also<br />

execute queries that specify the SHARE-LOCK condition as NO-LOCK queries and will<br />

also utilize block cursors <strong>for</strong> their result sets. You can shut off block cursor behavior<br />

and revert back to look-ahead cursors <strong>for</strong> NO-LOCK queries by setting the -Dsrv<br />

PRGRS_BLOCK_CURS,0. If you leave block cursors on but wish to turn off the block and/or<br />

look-ahead cursor optimizations <strong>for</strong> a specific query, you can set the QUERY-TUNING<br />

option QUERY-TUNING(NO-LOOKAHEAD) on your ABL statement.<br />

While block cursors increase efficiency, they might also require more memory than<br />

look-ahead cursors. Block cursors will try to reuse memory from previous result sets<br />

whenever possible. You can adjust the memory available to block cursors according to<br />

106 <strong>OpenEdge</strong> <strong>Data</strong> <strong>Management</strong>: <strong>Data</strong><strong>Server</strong> <strong>for</strong> <strong>Microsoft</strong> <strong>SQL</strong> <strong>Server</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!