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.

Indexes and sorting<br />

<strong>Data</strong>base design issues<br />

You create and maintain all indexes from within the MS <strong>SQL</strong> <strong>Server</strong> data source using<br />

native tools, rather than with the <strong>Data</strong> Dictionary. A data source index uses a logical<br />

pointer to the physical locations of table rows in order to sequence data access. You<br />

can add and drop indexes but you cannot use their names in queries. The data source<br />

alone ultimately decides when and how to use indexes; its decisions are not affected<br />

by the <strong>Data</strong><strong>Server</strong>.<br />

Give careful consideration to benefit and cost of creating indexes. Having indexes <strong>for</strong><br />

frequently executed queries can greatly improve record retrieval per<strong>for</strong>mance. An<br />

abundance of unused or infrequently used indexes can have a negative impact on<br />

per<strong>for</strong>mance due to the overhead cost of maintaining the indexes.<br />

Using index definitions in the MS <strong>SQL</strong> <strong>Server</strong> data source, the <strong>Data</strong><strong>Server</strong> builds index<br />

in<strong>for</strong>mation in the schema holder. <strong>OpenEdge</strong> index definitions <strong>for</strong> the data source<br />

schema serve two purposes:<br />

1. They allow you to use the OF option in ABL with the FOR EACH and FIND<br />

statements. Using the OF option improves the readability of your code. The OF<br />

keyword is equivalent to the <strong>SQL</strong> WHERE clause. You can use OF only when you<br />

have a field of the same name in two tables and the field is an index in at least one<br />

of the tables. There<strong>for</strong>e, since the custnum field is common to both the order and<br />

customer tables, you could write the following statement:<br />

FOR EACH order OF customer:<br />

2. They translate USE–INDEX to <strong>SQL</strong> ORDER BY <strong>for</strong> <strong>Data</strong><strong>Server</strong> operations. A MS <strong>SQL</strong><br />

<strong>Server</strong> data source uses the ORDER BY clause to assist in selecting the optimal<br />

index <strong>for</strong> the query. For example, if you define city-dept as a MS <strong>SQL</strong> <strong>Server</strong><br />

data source primary key on the city and department fields, it is a unique index<br />

in the schema holder. In this case, the following <strong>OpenEdge</strong> statements are<br />

equivalent when accessing the data source:<br />

FOR EACH employee USE-INDEX city-dept:<br />

FOR EACH employee BY city BY department:<br />

Note: If you do not specify a USE-INDEX or BY clause, your query will return<br />

records in an unpredictable order. If your application requires a predictable<br />

order, use include a USE-INDEX or BY clause.<br />

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

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

Saved successfully!

Ooh no, something went wrong!