System and method for query expression optimization
First Claim
1. A system for optimizing execution of a query expression on a database engine of a database server, comprising:
- a computer processor;
a database engine on a database server for receiving the query expression with a plurality of query language elements;
an evaluation counter module within the database engine, wherein the evaluation counter module increments an evaluation counter value corresponding to a query language element result;
a flag within the database engine, wherein the flag is configured to be set in the database engine when the evaluation counter value reaches a threshold value;
a seen counter module within the database engine, wherein the seen counter module increments a seen counter value corresponding to each of the query language elements when a query language element is evaluated;
a cost value module within the database engine, wherein the cost value module assigns a cost value to each of the query language elements determined by a duration of time that a query processor uses to evaluate each query language element; and
a module that reorders query language elements in the query expression in order of a most efficient query language element with a greatest probability of an early exit of the query expression evaluated first and a least efficient query language element with a lowest probability of an early exit of the query expression evaluated last in the query expression, wherein query language element efficiency is defined as the evaluation counter value divided by a product of the seen counter value and the cost value.
2 Assignments
0 Petitions
Accused Products
Abstract
A method provided for optimizing a query expression on a database engine of a database server. The query expression is sent to the database engine. The query expression contains a plurality of query language elements. The database engine initiates query processing of the query expression. An evaluation counter within the database engine increments an evaluation counter value corresponding to a query language element result. A flag is set within the database engine when the evaluation counter value reaches a threshold value. The database engine can then evaluate the efficiency of the query language elements in the query expression by comparing the evaluation counter value for each query language element against a set of optimization criteria.
70 Citations
15 Claims
-
1. A system for optimizing execution of a query expression on a database engine of a database server, comprising:
-
a computer processor; a database engine on a database server for receiving the query expression with a plurality of query language elements; an evaluation counter module within the database engine, wherein the evaluation counter module increments an evaluation counter value corresponding to a query language element result; a flag within the database engine, wherein the flag is configured to be set in the database engine when the evaluation counter value reaches a threshold value; a seen counter module within the database engine, wherein the seen counter module increments a seen counter value corresponding to each of the query language elements when a query language element is evaluated; a cost value module within the database engine, wherein the cost value module assigns a cost value to each of the query language elements determined by a duration of time that a query processor uses to evaluate each query language element; and a module that reorders query language elements in the query expression in order of a most efficient query language element with a greatest probability of an early exit of the query expression evaluated first and a least efficient query language element with a lowest probability of an early exit of the query expression evaluated last in the query expression, wherein query language element efficiency is defined as the evaluation counter value divided by a product of the seen counter value and the cost value. - View Dependent Claims (2)
-
-
3. A computer implemented method for optimizing a query expression on a database engine of a database server, comprising:
-
sending, by the computer, the query expression to the database engine, wherein the query expression contains a plurality of predicates; initiating, by the computer, query processing of the query expression; incrementing, by the computer, an evaluation counter, wherein the counter increments an evaluation counter value corresponding to a predicate when a predicate evaluation results in a Boolean result; setting, by the computer, a flag within the database engine when the evaluation counter value reaches a threshold value; incrementing, by the computer, a seen counter, wherein the seen counter increments a seen counter value corresponding to each of the plurality of predicates when a predicate is evaluated; assigning, by the computer, a cost value to each predicate of the plurality of predicates determined by a duration of time that a query processor uses to evaluate each predicate; and reordering, by the computer, predicates in the query expression in order of a most efficient predicate with a greatest probability of an early exit of the query expression evaluated first and a least efficient predicate with a lowest probability of an early exit of the query expression evaluated last in the query expression, wherein predicate efficiency is defined as the evaluation counter value divided by a product of the seen counter value and the cost value. - View Dependent Claims (4, 5, 6, 7, 8, 9, 10, 11, 12, 13)
-
-
14. A computer implemented method for optimizing a query expression on a database engine of a database server, comprising:
-
sending, by the computer, the query expression to the database engine, wherein the query expression contains a plurality of query language elements; initiating, by the computer, query processing of the query expression; incrementing, by the computer, an evaluation counter, wherein the counter increments an evaluation counter value corresponding to a query language element when a specified query language element evaluation results; setting, by the computer, a flag within the database engine when the evaluation counter value reaches a threshold value; incrementing, by the computer, a seen counter, wherein the seen counter increments a seen counter value corresponding to each of the query language elements when a query language element is evaluated; assigning, by the computer, a cost value to each of the query language elements determined by a duration of time that a query processor uses to evaluate each query language element; and reordering, by the computer, query language elements in the query expression in order of a most efficient query language element with a greatest probability of an early exit of the query expression evaluated first and a least efficient query language element with a lowest probability of an early exit of the query expression evaluated last in the query expression, wherein query language element efficiency is defined as the evaluation counter value divided by a product of the seen counter value and the cost value. - View Dependent Claims (15)
-
Specification