Indexes and sorting
- Last Updated: February 11, 2026
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
Indexes and sorting
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
OFoption in ABL with theFOR EACHandFINDstatements. Using theOFoption improves the readability of your code. TheOFkeyword is equivalent to the SQLWHEREclause. You can useOFonly 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 thecustnumfield is common to both theorderandcustomertables, you could write the following statement:FOR EACH order OF customer: -
They translate
USE-INDEXto SQLORDER BYfor DataServer operations. A MS SQL Server data source uses theORDER BYclause to assist in selecting the optimal index for the query. For example, if you definecity-deptas a MS SQL Server data source primary key on thecityanddepartmentfields, 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 aUSE-INDEXorBYclause, your query will return records in an unpredictable order. If your application requires a predictable order, use include aUSE-INDEXorBYclause.