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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 4: Additional Features to Enhance <strong>Data</strong><strong>Server</strong> Per<strong>for</strong>mance<br />

Caching records<br />

The <strong>Data</strong><strong>Server</strong> caches results sets from a MS <strong>SQL</strong> <strong>Server</strong> data source to enhance<br />

per<strong>for</strong>mance when using block cursors. It caches as much data as fits in its allocated<br />

cache size. When using firehose and/or lookahead calls, the allocations are made to fit<br />

the size of the result set. Depending on what kind of cursor a query is using, the<br />

<strong>Data</strong><strong>Server</strong> caches row identifiers or records:<br />

• Standard cursors — The <strong>Data</strong><strong>Server</strong> caches row identifiers (PROGRESS_RECID<br />

column or other unique index) <strong>for</strong> the results set. If you use the PROGRESS_RECID,<br />

each identifier requires 4 bytes of cache, there<strong>for</strong>e, a results set of 100 records<br />

requires 400 bytes of cache. If you do not use the PROGRESS_RECID field, the<br />

cache size might be greater if the selected unique index has a greater length than<br />

this field.<br />

• Lookahead cursors — The <strong>Data</strong><strong>Server</strong> caches complete records or partial<br />

records as specified by a field list. It uses the maximum length allowed <strong>for</strong> a row<br />

as defined in the MS <strong>SQL</strong> <strong>Server</strong> data source to calculate the record length, not<br />

the actual contents of the record. In addition to the defined row length, the record<br />

consists of a row identifier field; there<strong>for</strong>e, a row with a defined maximum length<br />

of 100 bytes requires 104 bytes of cache. If a column is longer than 256 bytes, the<br />

<strong>Data</strong><strong>Server</strong> refetches it.<br />

In the case of joins, each record in the cache is a result of the fields selected in the join.<br />

In addition to the record, there is a row identifier field (4 bytes) <strong>for</strong> each table involved<br />

in the join. For example, a three-way join adds 12 bytes to the cache <strong>for</strong> each record.<br />

You can affect the per<strong>for</strong>mance of a query by controlling the size of the cache when<br />

lookahead cursors are used. As queries generate different results, they benefit from<br />

different cache sizes. Generally, the larger the cache, the faster the per<strong>for</strong>mance.<br />

However, you must balance cache size against other memory requirements <strong>for</strong> your<br />

system. Consider also that continually adjusting cache size in an application might<br />

decrease per<strong>for</strong>mance as each adjustment requires the <strong>Data</strong><strong>Server</strong> to make several<br />

calls to the data source.<br />

To determine the optimal cache size <strong>for</strong> a query, experiment with different values <strong>for</strong><br />

CACHE–SIZE and use DEBUG EXTENDED to generate cursor statistics in the dataserv.lg<br />

file that you can examine. Aim <strong>for</strong> minimal cursor activity. The following example sets<br />

an optimal cache size <strong>for</strong> a particular query against the sports database:<br />

FOR EACH customer, EACH order OF customer WHERE order.ordnum GT 20<br />

QUERY-TUNING(CACHE-SIZE 20 DEBUG EXTENDED):<br />

174 <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!