Patent ID: 8332389

Claim:
A method comprising: executing a portion of an execution plan to produce a portion of records in a partial result set; if the executing the portion of the execution plan performs a first join of a table that eliminates more than a first threshold number of records from the partial result set, determining whether an estimated cost of forced primary is less than an estimated cost of a star join; if the estimated cost of the forced primary is less than the estimated cost of the star join, moving the table first in a join order in the execution plan, discarding the portion of the records in the partial result set, and re-starting the executing with a different portion of the execution plan to produce a different portion of the records; and if the estimated cost of the forced primary is not less than the estimated cost of the star join and the table that eliminates more than the first threshold of records from the partial result set is not first in the join order and has local selection, modifying the execution plan for star join pre-selection, wherein the modifying the execution plan for star join pre-selection further comprises specifying a scan of the table that eliminates more than the first threshold of records from the partial result set that is not first in the join order and has local selection to produce a temporary result set prior to a scan of a table that is first in the join order.