You create and maintain all indexes from within the MS SQL Server data source using native tools, rather than with the Data Dictionary. A data source index uses a logical pointer to the physical locations of table rows in order to sequence data access. You can add and drop indexes but you cannot use their names in queries. The data source alone ultimately decides when and how to use indexes; its decisions are not affected by the DataServer.
Give careful consideration to benefit and cost of creating indexes. Having indexes for frequently executed queries can greatly improve record retrieval performance. An abundance of unused or infrequently used indexes can have a negative impact on performance due to the overhead cost of maintaining the indexes.
Using index definitions in the MS SQL Server data source, the DataServer builds index information in the schema holder. OpenEdge index definitions for the data source schema serve two purposes:
They allow you to use the OF option in ABL with the FOR EACH and FIND statements. Using the OF option improves the readability of your code. The OF keyword is equivalent to the SQL WHERE clause. You can use OF only when you have a field of the same name in two tables and the field is an index in at least one of the tables. Therefore, since the custnum field is common to both the order and customer tables, you could write the following statement:
FOR EACH order OF customer:
They translate USE-INDEX to SQL ORDER BY for DataServer operations. A MS SQL Server data source uses the ORDER BY clause to assist in selecting the optimal index for the query. For example, if you define city-dept as a MS SQL Server data source primary key on the city and department fields, it is a unique index in the schema holder. In this case, the following OpenEdge statements are equivalent when accessing the data source:
FOR EACH employee USE-INDEX city-dept:
FOR EACH employee BY city BY department:
Note: If you do not specify a USE-INDEX or BY clause, your query will return records in an unpredictable order. If your application requires a predictable order, use include a USE-INDEX or BY clause.