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.

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

Writing queries <strong>for</strong> per<strong>for</strong>mance<br />

4–16<br />

This section provides a collection of tips and guidelines to follow when writing queries. For<br />

example, a query that processes a large number of rows per<strong>for</strong>ms best if it uses NO–LOCK,<br />

lookahead cursors, a large cache size, and a small field list.<br />

These tips and guidelines might improve the per<strong>for</strong>mance of your <strong>Data</strong><strong>Server</strong> applications. To<br />

assess the usefulness of a particular suggestion, apply it, then use the DEBUG diagnostic options<br />

to gather statistics on how your application runs:<br />

• Use FOR EACH, GET, and OPEN QUERY statements rather than FIND statements, which<br />

generally per<strong>for</strong>m more slowly. Consider using the FOR FIRST statement instead of<br />

FIND FIRST.<br />

The only exception is that FIND LAST is faster than GET LAST. This is because GET LAST<br />

causes the client to process all of the records; the FIND LAST statement allows the server to<br />

retrieve the last record.<br />

• Use field lists.<br />

• Use the QUERY–TUNING options.<br />

• Use lookahead cursors.<br />

• Use NO–LOCK where possible.<br />

• Avoid specifying lock upgrades. Instead, allow the <strong>Data</strong><strong>Server</strong> and the MS <strong>SQL</strong> <strong>Server</strong><br />

data source to handle lock upgrades.<br />

• Do not ask <strong>for</strong> a particular ordering of results with USE–INDEX or BY clauses unless your<br />

application requires it. Instead, allow the <strong>Data</strong><strong>Server</strong> and the MS <strong>SQL</strong> <strong>Server</strong> data source<br />

to determine the most efficient index (if any) <strong>for</strong> processing a query and avoid the<br />

overhead of sorting results.<br />

• If you use a BY clause that will sort a large amount of data, make sure a corresponding<br />

index exists in your data source to make sorting efficient. In some cases it may also be<br />

desirable to have indexes over columns used in WHERE clause selection criteria.<br />

• For aggregates, use either the RUN–STORED–PROCEDURE send–sql–statement syntax or an<br />

<strong>OpenEdge</strong> <strong>SQL</strong> statement. If you use an <strong>OpenEdge</strong> <strong>SQL</strong> statement with a cursor, declare<br />

the cursor read-only.<br />

• When you test <strong>for</strong> the existence of a record, use the CAN–FIND FIRST function, which does<br />

not retrieve the record if the <strong>Data</strong><strong>Server</strong> passes the entire WHERE clause to the MS <strong>SQL</strong><br />

<strong>Server</strong> data source <strong>for</strong> processing. However, avoid nesting CAN–FIND functions.<br />

• Avoid using the RECID function. Instead, use the ROWID function.

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

Saved successfully!

Ooh no, something went wrong!