Optimizing Sorts

Next, if the request specifies a sort operation, the data adapter must determine how to sort the data. The data adapter transfers the sort operation to the RDBMS only when:

For a discussion of these conditions, see Optimizing Joins.

Under these conditions, the data adapter invokes one of the following types of RDBMS-managed sorting:

  1. If the request does not use the direct operators FST. and LST., the data adapter translates sort phrases (BY or ACROSS) into SQL ORDER BY clauses, thus passing responsibility for the primary sorting of data to the RDBMS. Note that BY TOTAL phrases are not optimized.

  1. When the data adapter determines that it will retrieve at most one segment instance per sort break, it translates FOCUS FST. and LST. operators to SQL MIN and MAX operators and translates sort phrases (BY and ACROSS) into SQL ORDER BY clauses. The data adapter applies this technique in requests that explicitly specify the FST. or LST. operators and in requests that implicitly use them by referencing a non-numeric field in a report heading or footing.

  1. If the report request contains FST. or LST. operators on a segment that may return multiple instances, the data adapter directs the RDBMS to sort the data by primary key in the sequence specified by the Access File KEYORDER attribute. From this, the data adapter retrieves column values for the logically first (FST.) or last (LST.) key values of the returned data. After the RDBMS sort, FOCUS re-sorts the data according to the sort phrases.

Note:

From a performance standpoint, consider using the TABLEF command in conjunction with RDBMS-managed sorting to free FOCUS from having to verify the sort order. Refer to Advanced Reporting Techniques, for the TABLEF command.


Information Builders