Triggering hard parses
First Claim
1. A method comprising:
- in response to receiving a first query, generating a first execution plan that is used to execute the first query and that involves accessing a particular database object;
executing the first query by executing the first execution plan;
storing a change threshold that indicates a first number of changes to the particular database object or a first change in size of the particular database object;
receiving a second query, wherein the first execution plan may be used to execute the second query;
in response to receiving the second query;
determining a change metric that is associated with the particular database object, wherein the change metric indicates a second number of changes to the particular database object or a second change in size of the particular database object; and
determining, based on a difference between the change metric and the change threshold, whether to generate an execution plan for the second query;
in response to determining to generate an execution plan for the second query, generating a second execution plan;
determining whether the second execution plan is the same as the first execution plan; and
modifying the change threshold in response to determining that the second execution plan is the same as the first execution plan;
wherein the method is performed by one or more computing devices.
1 Assignment
0 Petitions
Accused Products
Abstract
Techniques for processing queries are provided. In one approach, an execution plan for a query includes multiple sub-plans, one or more of which are selected at runtime while one or more other sub-plans are not executed during execution of the execution plan. In another approach, data about misestimate is generated and stored persistently for subsequent queries. In another approach, statistics for a database object are generated automatically and efficiently while the database object is created or data items are added thereto. In another approach, a hybrid histogram is created that includes a feature of frequency histograms and a feature of height-balanced histograms. In another approach, computer jobs are executed in such a way to avoid deadlock. In another approach, changes to a database object trigger a hard parse of a query even though an execution plan already exists for the query.
31 Citations
19 Claims
-
1. A method comprising:
-
in response to receiving a first query, generating a first execution plan that is used to execute the first query and that involves accessing a particular database object; executing the first query by executing the first execution plan; storing a change threshold that indicates a first number of changes to the particular database object or a first change in size of the particular database object; receiving a second query, wherein the first execution plan may be used to execute the second query; in response to receiving the second query; determining a change metric that is associated with the particular database object, wherein the change metric indicates a second number of changes to the particular database object or a second change in size of the particular database object; and determining, based on a difference between the change metric and the change threshold, whether to generate an execution plan for the second query; in response to determining to generate an execution plan for the second query, generating a second execution plan; determining whether the second execution plan is the same as the first execution plan; and modifying the change threshold in response to determining that the second execution plan is the same as the first execution plan; wherein the method is performed by one or more computing devices. - View Dependent Claims (2, 3, 4, 5, 6, 9)
-
-
7. A method comprising:
-
while executing a first execution plan, for a first query, that indicates a database object and a plurality of operations, generating particular statistics about an operation, of the plurality of operations, that is (a) a join operation of multiple database objects that includes the database object or (b) a filter operation on the database object, wherein the filter operation includes a predicate that was applied to the database object; storing the particular statistics that indicate information about the join operation or the filter operation; after storing the particular statistics and in response to receiving a second query that is not equivalent to the first query, determining whether the particular statistics are relevant to the second query; wherein the first execution plan cannot be used to generate valid results for the second query; wherein determining whether the particular statistics are relevant to the second query comprises; identifying the database object in the second query; using an identifier of the database object to identify an entry in a data structure that comprises a plurality of entries, each containing certain statistics about one or more operations involving different database objects; and analyzing the entry to determine whether a particular join or a particular predicate in the second query matches, in the entry, the predicate or a join that was indicated in the first query; wherein the operation is the join operation that involves the database object and one or more other database objects; wherein the join indicated in the first query indicates a first order of the database object and the one or more other database objects; wherein the particular join in the second query indicates a second order of the database object and the one or more other database objects; wherein the first order is different than the second order; indicating that the particular join in the second query matches the join indicated in the first query; in response to determining that the particular statistics are relevant to the second query, optimizing the second query based on the particular statistics, wherein optimizing comprises selecting a second execution plan based on the particular statistics; and executing the second execution plan. - View Dependent Claims (8, 10, 11, 12, 18, 19)
-
-
13. One or more storage media storing instructions which, when executed by one or more processors, further cause:
-
in response to receiving a first query, generating a first execution plan that is used to execute the first query and that involves accessing a particular database object; executing the first query by executing the first execution plan; storing a change threshold that indicates a first number of changes to the particular database object or a first change in size of the particular database object; receiving a second query, wherein the first execution plan may be used to execute the second query; and in response to receiving the second query; determining a change metric that is associated with the particular database object, wherein the change metric indicates a second number of changes to the particular database object or a second change in size of the particular database object; and determining, based on a difference between the change metric and the change threshold, whether to generate an execution plan for the second query; in response to determining to generate an execution plan for the second query, generating a second execution plan; determining whether the second execution plan is the same as the first execution plan; and modifying the change threshold in response to determining that the second execution plan is the same as the first execution plan. - View Dependent Claims (14, 15, 17)
-
-
16. One or more storage media storing instructions which, when executed by one or more processors, cause:
-
while executing a first execution plan, for a first query, that indicates a database object and a plurality of operations, generating particular statistics about an operation, of the plurality of operations, that is (a) a join operation that involves the database object or (b) a filter operation that includes a predicate that is applied to the database object; storing the particular statistics that indicate information about the join operation or the filter operation; after storing the particular statistics and in response to receiving a second query that is not equivalent to the first query, determining whether the particular statistics are relevant to the second query; wherein the first execution plan cannot be used to generate valid results for the second query; wherein determining whether the particular statistics are relevant to the second query comprises; identifying the database object in the second query; using an identifier of the database object to identify an entry in a data structure that comprises a plurality of entries, each containing certain statistics about one or more operations involving different database objects; and analyzing the entry to determine whether a particular join or a particular predicate in the second query matches, in the entry, the predicate or a join that was indicated in the first query; wherein the operation is the join operation that involves the database object and one or more other database objects; wherein the join indicated in the first query indicates a first order of the database object and the one or more other database objects; wherein the particular join in the second query indicates a second order of the database object and the one or more other database objects; wherein the first order is different than the second order; indicating that the particular join in the second query matches the join indicated in the first query; in response to determining that the particular statistics are relevant to the second query, optimizing the second query based on the particular statistics, wherein optimizing comprises selecting a second execution plan based on the particular statistics; and executing the second execution plan.
-
Specification