Patent ID: 7308437

Claim:
A method of optimizing a database query, the method comprising: determining a retrieval status for a resource used by the database query, wherein determining the retrieval status includes determining a percentage of the resource that is resident in a working memory; generating an access plan for the database query using the determined retrieval status for the resource, wherein generating the access plan includes: generating a plurality of alternate access plans: calculating a cost for each alternate access plan using the determined retrieval status for the resource; and selecting one of the alternate access plans based upon the calculated costs for each alternate access plan: storing the access plan, including associating with the stored access plan a retrieval status assumption for the stored access plan, the retrieval status assumption representing the determined retrieval status used to generate the access plan; and in response to a request to execute the stored access plan: determining a current retrieval status for the resource, wherein determining the current retrieval status includes determining a percentage of the resource that is currently resident in the working memory; comparing the current retrieval status with the retrieval status assumption: and selectively generating another access plan for the database query using the current retrieval status based upon the comparison of the current retrieval status with the retrieval status assumption.