INDEX-INFORMATION attribute

This attribute allows you to retrieve information about the indexes the AVM uses to retrieve the records that satisfy the selection criteria. There is also an INDEX-INFORMATION function for static queries, but the dynamic method is especially useful as part of a procedure that defines selection criteria at run time for either a statically defined or dynamic query. If there is variability in the WHERE clause your procedure accepts or generates at run time (perhaps based on a specific user request), the record retrieval might be highly inefficient if the query requires searching non-indexed field values for large tables. The INDEX-INFORMATION takes a single INTEGER argument, which is the join level you want information for. For example, a value of 1 means that you want index information for the first table in the join.

If the AVM is able to use one or more index brackets to satisfy the query so that it does not have to read all the records in a table, the method returns a comma-separated list of the indexes used. The AVM uses more than one index to resolve a complex query if this results in the smallest number of non-indexed fields being searched.

If the AVM is unable to use an index to reduce the number of records read because the selection involves non-indexed fields or fields that are not the primary components of a multi-component index, then it returns the "WHOLE-INDEX" string, followed by a comma, followed by the name of the index the AVM uses to navigate the records. This is normally the primary index of the table.

You can use the INDEX-INFORMATION() method to warn users of potentially inefficient queries or prevent them from executing queries that cannot use an index.

You must prepare the query before you can query its INDEX-INFORMATION.

NUM-RESULTS and CURRENT-RESULT-ROW attributes

The NUM-RESULTS and CURRENT-RESULT-ROW attributes correspond to the static query functions of the same names that you’re already familiar with. They return the number of rows in the query’s current result list and the current row position within that list, respectively.