Optimizer dynamic sampling
First Claim
1. A method used for optimizing queries, the method comprising the steps of:
- receiving a first query that requires access to a first table;
generating a first execution plan for executing said first query;
based on a set of one or more factors, determining whether to execute another query to access a subset of rows as a sample from said first table and to generate results used to evaluate efficiency of execution plans for executing said first query;
wherein said one or more factors include at least one factor that reflects the efficacy of executing said other query to evaluate the efficiency of execution plans for executing said first query;
if, based on said one or more factors, it is determined the other query should be executed, then issuing said other query to generate first results; and
determining a second execution plan for executing said first query based on said first results.
1 Assignment
0 Petitions
Accused Products
Abstract
Described herein are approaches to implementing dynamic sampling in a way that lessens or eliminates the additional overhead incurred to perform dynamic sampling. Also described are techniques for determining characteristics about predicates not previously determined by conventional techniques for dynamic sampling. Dynamic sampling is used by a query optimizer to dynamically estimate predicate selectivities and statistics. When a database statement is received by a database server, an initial analysis of the database statement is made to determine the efficacy of dynamic sampling, that is, to determine whether optimization of the query would benefit from dynamic sampling and whether performance is not excessively impacted by the dynamic sampling process. If this analysis determines dynamic sampling should be used, then dynamic sampling is undertaken.
120 Citations
17 Claims
-
1. A method used for optimizing queries, the method comprising the steps of:
-
receiving a first query that requires access to a first table;
generating a first execution plan for executing said first query;
based on a set of one or more factors, determining whether to execute another query to access a subset of rows as a sample from said first table and to generate results used to evaluate efficiency of execution plans for executing said first query;
wherein said one or more factors include at least one factor that reflects the efficacy of executing said other query to evaluate the efficiency of execution plans for executing said first query;
if, based on said one or more factors, it is determined the other query should be executed, then issuing said other query to generate first results; and
determining a second execution plan for executing said first query based on said first results. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-
-
12. A method used for optimizing queries, the method comprising the steps of:
-
receiving a first query that requires access to a table;
in response to receiving said first query, generating another query to generate results that may be used to evaluate the efficiency of execution plans for executing said first query;
wherein said first query requires access to a first column in said table;
wherein said first column contains unique values that are each unique relative to all other values in the first column;
wherein said first query contains a predicate that is based on a expression;
wherein said expression is based on said first column; and
determining whether said results indicate, for a subset of rows in the table, whether said expression is unique for each row of said subset relative to the other rows in said subset.
-
-
13. A method used for optimizing queries, the method comprising the steps of:
-
receiving a first query that requires access to a table and that includes a predicate;
in response to receiving said first query, generating another query to generate results that may be used to evaluate the efficiency of execution plans for executing said first query;
wherein said other query accesses a subset of the rows of said table;
determining the portion of rows in said subset that satisfy said predicate; and
if said portion is not greater than a threshold, then;
establishing a default value as an estimate of the selectivity of the predicate; and
based on said estimate, determining an execution plan for executing said first query.
-
-
14. A method used for optimizing queries, the method comprising the steps of:
-
receiving a first query that requires access to a table and that includes a predicate;
in response to receiving said first query, generating another query to generate results that may be used to evaluate the efficiency of execution plans for executing said first query;
wherein said other query accesses a first subset of the rows of said table;
determining the portion of rows in said first subset that satisfy said predicate; and
if said portion is not greater than a threshold, then establishing a default value as an estimate of selectivity of the predicate; and
based on said estimate, determining an execution plan for executing said first query.
-
-
15. A method used for optimizing queries, the method comprising the steps of:
-
receiving a first query that requires access to a table and that includes a predicate;
in response to receiving said first query, generating another query to generate results that may be used to evaluate the efficiency of execution plans for executing said first query;
wherein said other query accesses a first subset of the rows of said table;
determining the portion of rows in said first subset that satisfy said predicate; and
if said portion is not greater than a threshold, then causing traversal of an index to determine a number of rows in said table that satisfy the predicate.
-
-
16. A method used for performing dynamic sampling to optimize queries, the method comprising the steps of:
-
receiving a query that requires access to a table;
in response to receiving said first query, generating another query to generate results that may be used to evaluate the efficiency of execution plans for executing said first query;
wherein execution of said other query;
uses resources;
entails access to first data stored in said table and to metadata describing said table;
making a determination of how to divide said resources between accessing said first data and accessing said metadata; and
wherein the step of generating said other query includes generating said query so that said execution of said query uses said resources according to said determination. - View Dependent Claims (17)
-
Specification