SQL execution plan verification
First Claim
1. A method comprising:
- maintaining, at a database server, plan verification data that identifies one or more query execution plans that have been designated as acceptable for use by the database server to execute a database commands, the database command being a query statement that instructs the database server to perform one or more operations on data stored in a database;
receiving, at the database server, a first request to execute a database command;
at the database server, identifying a plurality of alternative query execution plans for executing the database command in response to the first request, the plurality of alternative query execution plans including at least a first query execution plan and a second query execution plan that is different than the first query execution plan;
the database server selecting, from the plurality of alternative query execution plans identified by the database server, a query execution plan to execute the database command in response to the first request, wherein the database server selects the second query execution plan based at least in part on determining;
a) that the plan verification data indicates that the second query execution plan has been designated as acceptable for executing the database command, and b) that the plan verification data does not yet indicate that the first query execution plan has been designated as acceptable for executing the database command;
subsequent to responding to the first request, the database server testing actual performance of the first query execution plan by executing the first query execution plan to determine actual performance statistics for the first query execution plan;
based at least on the determined actual performance statistics, the database server determining to update the plan verification data to designate the first query execution plan as acceptable for executing the database command;
subsequent to updating the plan verification data to indicate that the first query execution plan has been verified, the database server receiving a second request to execute the same database command;
at the database server, identifying the plurality of alternative query execution plans for executing the database command in response to the second request; and
based at least in part on determining that the updated verification data indicates that the first query execution plan has been verified, the database server selecting the first query execution plan to execute the database command in response to the second request;
wherein the method is performed by one or more computing devices.
1 Assignment
0 Petitions
Accused Products
Abstract
Approaches, techniques, and mechanisms are disclosed for ensuring that a database command is executed according to a query plan that has been verified to be actually optimal. Except in rare circumstances, a database server does not execute a query plan unless it is first verified by the database server. The database server receives a request to execute a database command. The database server determines an unverified plan is the best plan for satisfying the request. Rather than risk the unknown behavior of an unverified plan, the database server instead satisfies the request according to a verified plan. Subsequently—for example as part of a scheduled job—the database server executes the unverified plan to determine performance statistics. Based at least on the performance statistics, the database server determines whether or not to verify the unverified plan. Techniques for concurrent and optimistic verifications are also disclosed.
168 Citations
38 Claims
-
1. A method comprising:
-
maintaining, at a database server, plan verification data that identifies one or more query execution plans that have been designated as acceptable for use by the database server to execute a database commands, the database command being a query statement that instructs the database server to perform one or more operations on data stored in a database; receiving, at the database server, a first request to execute a database command; at the database server, identifying a plurality of alternative query execution plans for executing the database command in response to the first request, the plurality of alternative query execution plans including at least a first query execution plan and a second query execution plan that is different than the first query execution plan; the database server selecting, from the plurality of alternative query execution plans identified by the database server, a query execution plan to execute the database command in response to the first request, wherein the database server selects the second query execution plan based at least in part on determining;
a) that the plan verification data indicates that the second query execution plan has been designated as acceptable for executing the database command, and b) that the plan verification data does not yet indicate that the first query execution plan has been designated as acceptable for executing the database command;subsequent to responding to the first request, the database server testing actual performance of the first query execution plan by executing the first query execution plan to determine actual performance statistics for the first query execution plan; based at least on the determined actual performance statistics, the database server determining to update the plan verification data to designate the first query execution plan as acceptable for executing the database command; subsequent to updating the plan verification data to indicate that the first query execution plan has been verified, the database server receiving a second request to execute the same database command; at the database server, identifying the plurality of alternative query execution plans for executing the database command in response to the second request; and based at least in part on determining that the updated verification data indicates that the first query execution plan has been verified, the database server selecting the first query execution plan to execute the database command in response to the second request; wherein the method is performed by one or more computing devices. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32)
-
-
14. A method comprising:
-
maintaining, at a database server, plan verification data that identifies one or more query execution plans that have been designated as acceptable for use by the database server to execute a database commands, the database command being a query statement that instructs the database server to perform one or more operations on data stored in a database; receiving, at the database server, a first request to execute a database command; at the database server, identifying a first query execution plan for executing the database command in response to the first request; in response to the first request, and further in response to determining that the plan verification data does not yet indicate whether the first query execution plan has been designated as acceptable for use by the database server to execute the database command, the database server executing the database command according to the first query execution plan concurrent to executing the database command according to a second query execution plan, the second query execution plan being different than the first query execution plan and having been previously designated as acceptable for use by the database server to execute the database command; the database server responding to the first request using results returned from one of the concurrently executed first query execution plan and second query execution plan; and responsive to the executing of the first query execution plan completing before the executing of the second query execution plan completes, the database server updating the plan verification data to indicate that the first query execution plan has been designated as acceptable for use by the database server to execute the database command; wherein the method is performed by one or more computing devices. - View Dependent Claims (15, 33, 34)
-
-
16. A method comprising:
-
maintaining, at a database server, plan verification data that identifies one or more query execution plans that have been designated as acceptable for use by the database server to execute a database commands, the database command being a query statement that instructs the database server to perform one or more operations on data stored in a database; receiving, at the database server, a first request to execute a database command; at the database server, identifying at least a first query execution plan for executing the database command in response to the first request; based at least in part on determining that the first query execution plan is a new query execution plan, for which no plan verification data is maintained, responding to the first request by executing the database command according to the first query execution plan; collecting actual performance statistics while executing the database command according to the first query execution plan; based at least on the actual performance statistics, the database server updating the plan verification data to designate the first query execution plan as unacceptable for executing the database command; subsequent to updating the plan verification data, the database server receiving a second request to execute the same database command; at the database server, identifying the first query execution plan for executing the database command in response to the second request; and based at least in part on determining that the updated verification data designates that (a) the first query execution plan is unacceptable for executing the database command and (b) that a second query execution plan has been designated as acceptable for executing the database command, responding to the second request by executing the database command according to the second query execution plan, the second query execution plan being different than the first query execution plan; wherein the method is performed by one or more computing devices. - View Dependent Claims (17, 18, 19, 35, 36, 37, 38)
-
Specification