6. The one or more storage media of claim 1 , wherein the query is a first query, wherein the instructions, when executed by the one or more processors, further cause: prior to receiving a second query that is semantically equivalent to the first query, storing sub-plan indication data that indicates that the first sub-plan was executed and not the second sub-plan; in response to receiving the second query: determining to use the execution plan; while executing the execution plan, determining, based on the sub-plan indication data, to execute the first sub-plan without determining whether the one or more criteria are satisfied.
1. One or more storage media storing instructions which, when executed by one or more processors, cause: in response to receiving a query, identifying an execution plan that comprises a plurality of sub-plans that includes a first sub-plan and a second sub-plan; wherein the first sub-plan comprises a first operation, of a first type, that can be performed during execution of the execution plan; wherein the second sub-plan comprises a second operation, of a second type that is different than the first type, that can be performed during execution of the execution plan; wherein no sub-plan in the plurality of sub-plans contains all operations that are required to generate a valid result of the query; wherein the execution plan comprises one or more operations that are not in the first sub-plan or the second sub-plan; after determining the execution plan, executing a portion of the execution plan, wherein executing the portion of the execution plan comprises storing, in a buffer associated with a particular size, temporary results of executing the portion, wherein the particular size is less than a size of a table from which the temporary results are generated; in response to determining that an amount of data in the buffer has reached the particular size, determining whether one or more criteria are satisfied; if the one or more criteria are satisfied, then executing the first sub-plan of the plurality of sub-plans without executing the second sub-plan; if the one or more criteria are not satisfied, then executing the second sub-plan of the plurality of sub-plans without executing the first sub-plan; generating a result of the query by completing execution of the execution plan and without reoptimizing the query.