Patent ID: 7937385

Claim:
A computer-implemented method for obtaining a plan for executing a query in a relational database, comprising: Receiving, by the computer, a query for data in the relational database, wherein the query specifies N tables in the relational database from which data is to be retrieved, where N is an integer; determining, by the computer, whether syntax of the query matches syntax of a plan in a plan cache for executing the query; responsive to the syntax of the query matching the syntax of a plan in the plan cache for executing the query, identifying, by the computer, matches between generic table formats of the N tables specified in the query to generic table formats of N tables specified in the plan; obtaining, by the computer, a plan for executing the query based on whether the syntax of the query matches the syntax of the plan and based on identified matches between the generic table formats of the N tables specified in the query to the generic table formats of the N tables specified in the plan; and wherein the step of obtaining a plan comprises using the plan in the plan cache for executing the query or generating a new plan for executing the query based on the whether the syntax of the query matches the syntax of the plan in the plan cache for executing the query and based on identified matches between the generic table formats of the N tables specified in the query to the generic table formats of the N tables specified in the plan.