Patent ID: 7567952
Filing Date: 2009-07-28
Classification: G06F,Y10S

Abstract:
1. An apparatus comprising: at least one processor; a memory coupled to the at least one processor containing a database of records; a query residing in the memory that includes a Select statement with a Fetch First n Rows Only clause, where n is an integer variable; a query optimizer residing in the memory and executed by the at least one processor, wherein 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 prior to ordering the records and then return a first n rows; and wherein the query optimizer further determines the query contains an Order By clause, that an index exists for each predicate in the Where clause, and the field of the Order By clause exists in each index; and the query optimizer generates an access plan that eliminates records prior to a sort by fetching only n rows from each index and then returning n rows after sorting a set of records that includes the n rows from each index.