In an information retrieval system, a query optimization method transforms
maximum or minimum function aggregation predicates on a non-indexed
column into a single sort function. The method evaluates the query to
identify a table and a predicate equating a column of the table to a
sub-query that applies a maximum or minimum aggregation function to the
column to return an aggregate value for the column. The aggregate value
is used for selecting rows from the table to produce a query result. A
determination is then made whether an index has not been created using
the column of the table. In response to these steps of evaluating and
determining, the method reforms the query as a sort function on the
column. The sort function scans the table once to provide the query
result.