An apparatus and method to optimize a query access plan in a computer
database system. In preferred embodiments, the query optimizer determines
the query can be optimized and generates for the query an optimized
access plan that eliminates records defined by a Where clause and one or
more ordering criteria prior to ordering the records (sorting or
grouping) and then returning a first n rows.