Patent ID: 8161037

Claim:
A method for optimizing a query, the method comprising the steps of: (A) storing a performance specification for the query and an access plan for the query in an access plan cache, the stored performance specification specifying a desired maximum disk input/output (I/O) operations for the query that comprises an average of disk I/O operations over the last N executions of the query, where N is a predetermined positive integer; (B) determining number of disk I/O operations required to execute the query using an access plan stored in the access plan cache; (C) comparing the number of disk I/O operations required to execute the query in step (B) with the stored performance specification for the query; (D) generating a new access plan if the number of disk I/O operations required to execute the query using the access plan stored for the query exceeds the stored performance specification for the query; (E) determining number of disk I/O operations for executing the new access plan; (F) if a new access plan is generated in step (D) that has a number of disk I/O operations in step (E) that satisfies the performance specification for the query, storing the new access plan in an entry in the access plan cache that corresponds to the query and updating the performance specification corresponding to the query; (G) if a new access plan is not generated in step (D) that has a number of disk I/O operations determined in step (E) that satisfies the corresponding stored performance specification for the query, selecting a new access plan that had the best number of disk I/O operations in step (E), storing the new access plan in the entry in the access plan cache that corresponds to the query, and using the best number of disk I/O operations in step (E) to generate a new stored performance specification corresponding to the query.