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.

Caching records<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 per<strong>for</strong>mance<br />

when using block cursors. It caches as much data as fits in its allocated cache size. When using<br />

firehose and/or lookahead calls, the allocations are made to fit the size of the result set.<br />

Depending on what kind of cursor a query is using, the <strong>Data</strong><strong>Server</strong> caches row identifiers or<br />

records:<br />

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

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

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

cache. If you do not use the PROGRESS_RECID field, the cache size might be greater if the<br />

selected unique index has a greater length than this field.<br />

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

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

MS <strong>SQL</strong> <strong>Server</strong> data source to calculate the record length, not the actual contents of the<br />

record. In addition to the defined row length, the record consists of a row identifier field;<br />

there<strong>for</strong>e, a row with a defined maximum length of 100 bytes requires 104 bytes of cache.<br />

If a column is longer than 256 bytes, the <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. In<br />

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

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 lookahead<br />

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

Generally, the larger the cache, the faster the per<strong>for</strong>mance. However, you must balance cache<br />

size against other memory requirements <strong>for</strong> your system. Consider also that continually<br />

adjusting cache size in an application might decrease per<strong>for</strong>mance as each adjustment requires<br />

the <strong>Data</strong><strong>Server</strong> to make several 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 file that<br />

you can examine. Aim <strong>for</strong> minimal cursor activity. The following example sets an optimal cache<br />

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 />

4–13

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

Saved successfully!

Ooh no, something went wrong!