110. The machine-readable storage medium of claim 108 , wherein the instructions that cause choosing the particular query from the set of local-best queries comprise instructions which, when executed by the one or more processors, cause the one or more processors to perform the steps of: establishing, as a global-best query, the local-best query for a first starting query of the multiple starting queries; after determining each local-best query for each starting query, determining whether the local-best cost for the local-best query is better than a global-best cost for the global-best query; and if the local-best cost is better than the global-best cost, then: establishing the local-best cost as the global-best cost; and establishing the local-best query as the global-best query.
108. A machine-readable storage medium storing one or more sequences of instructions for processing a query, which instructions, when executed by one or more processors, cause the one or more processors to perform steps comprising: receiving the query, wherein the query comprises one or more query blocks; determining multiple starting queries based on the query and one or more heuristics; for each starting query of the multiple starting queries: establishing said each starting query as a local-best query; determining a set of candidate queries and costs, wherein the costs include a cost for each candidate query in the set of candidate queries, wherein each candidate query in the set of candidate queries is determined based on the local-best query and an alternative state for a particular query block of the one or more query blocks, and wherein, if a specific cost for a specific candidate query satisfies a first particular mathematical relationship with a local-best cost for the local-best query, then establishing the specific candidate query as the local-best query; wherein each candidate query in the set of candidate queries is semantically equivalent to the query; choosing a particular query from a set of local-best queries based on costs for each query in the set of local-best queries, wherein the set of local-best queries comprises the local-best query for each set of candidate queries; and executing the particular query in response to a request to execute the query.