Patent ID: 7313553

Claim:
An apparatus comprising: at least one processor; a memory coupled to the at least one processor; a database table residing in the memory; a query residing in the memory that accesses the database table; and a query optimizer residing in the memory and executed by the at least one processor, wherein the query optimizer analyzes the query, and if no optimal index for the query exists, the query optimizer determines if a sub-optimal index exists, a sub-optimal index including at least one key referenced in the query and additionally including at least one additional key that prevents traversal of the sub-optimal index to determine the number of rows that the query will return, wherein if a sub-optimal index exists, the query optimizer, for each additional key in the sub-optimal index, reads a frequent values list that corresponds to the additional key, the query optimizer rewriting the query using the frequent values list in a manner that allows probing the sub-optimal index according to the rewritten query, the query optimizer thereby determining from the sub-optimal index an estimated number of rows in the database table that satisfy the query, the query optimizer optimizing the query based on the estimated number of rows in the database table that satisfy the query.