Patent ID: 7184998

Claim:
In a database system, a method for constructing an optimal query execution plan for executing a query, the method comprising: receiving a query specifying at least one join condition between two or more database tables; identifying each query block within said query, each query block comprising an atomic portion of said query; creating subplans for each query block based on grouping quantifiers used in outer joins of each query block; determining at least one favorable access plan for each subplan of each query block, said at least one favorable access plan determined based at least in part on estimated execution costs; wherein determining at least one favorable access plan for each subplan includes generating at least one access plan for different sets of column references used in the subplan whose tables are outside the subplan; generating an optimal access plan for each query block based upon said at least one favorable access plan determine for each subplan; and constructing an optimal query execution plan based upon said optimal access plan generated for each query block.