System and method for processing queries having an inner query block containing a grouping operator
First Claim
1. A method of processing a query in a database system, comprising the computer-implemented steps of:
- receiving an original query that contains an inner query block with a grouping operator, said inner query block being embedded in an outer query block;
transforming the original query into a transformed query by;
removing the inner query block from the original query, and merging portions of the inner query block into the outer query block; and
processing the transformed query.
2 Assignments
0 Petitions
Accused Products
Abstract
Queries having a outer query block enclosing an inner query block, such as a reference to a view or a subquery, with a grouping operator, such as GROUP or DISTINCT, are transformed by merging the inner query block into the outer query block. The FROM clause of the transformed query includes the tables referenced in the FROM clauses of the outer query block and the inner query block. A new GROUP BY clause is created for the outer query block that contains the rowids of tables referenced in the FROM list of the original query and the expressions in the GROUP BY clause of the inner query block. The outer query block can be split if the outer query block also contains a GROUP BY or HAVING clause.
-
Citations
30 Claims
-
1. A method of processing a query in a database system, comprising the computer-implemented steps of:
-
receiving an original query that contains an inner query block with a grouping operator, said inner query block being embedded in an outer query block;
transforming the original query into a transformed query by;
removing the inner query block from the original query, and merging portions of the inner query block into the outer query block; and
processing the transformed query. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
inserting a HAVING clause into the outer query block, and moving a predicate of a WHERE clause of the outer query block into said HAVING clause, said predicate referencing a column in the view that is aggregated.
-
-
9. The method of claim 5, wherein the step of transforming includes the steps of:
-
splitting the outer query block into a first outer query block and a second outer query block, wherein the first outer query block encloses said second outer query block and includes a first outer query block GROUP BY or HAVING clause of the outer query block; and
merging the inner query block into the second outer query block.
-
-
10. The method of claim 4, wherein the grouping operator includes an inner block DISTINCT qualifier for the view.
-
11. The method of claim 10, wherein the step of transforming includes the steps of:
-
splitting the outer query block into a first outer query block and a second outer query block, wherein;
the first outer query block encloses said second outer query block, the second outer query block includes a DISTINCT qualifier and contains a WHERE clause of the outer query block and;
migrating the DISTINCT qualifier from the inner query block to the second outer query block; and
merging the inner query block into the second outer query block.
-
-
12. The method of claim 10, wherein the step of transforming includes converting the inner query block into an equivalent inner query block with a GROUP BY clause.
-
13. The method of claim 3, wherein the inner query block includes a subquery.
-
14. The method of claim 13, wherein the subquery is a non-correlated subquery.
-
15. The method of claim 14, wherein the step of transforming includes the step of converting the outer query block into an equivalent outer query block referencing a view based on the non-correlated subquery.
-
16. A computer-readable medium bearing instructions for processing a query in a database system, said instructions, when executed, arranged for causing one or more processors to perform the steps of:
-
receiving an original query that contains an inner query block with a grouping operator, said inner query block being embedded in an outer query block;
transforming the original query into a transformed query by;
removing the inner query block from the original query, and merging portions of the inner query block into the outer query block; and
processing the transformed query. - View Dependent Claims (17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30)
inserting a HAVING clause into the outer query block, and moving a predicate of a WHERE clause of the outer query block into said HAVING clause, said predicate referencing a column in the view that is aggregated.
-
-
24. The computer-readable medium of claim 20, wherein the step of transforming includes the steps of:
-
splitting the outer query block into a first outer query block and a second outer query block, wherein the first outer query block encloses said second outer query block and includes a first outer query block GROUP BY or HAVING clause of the outer query block; and
merging the inner query block into the second outer query block.
-
-
25. The computer-readable medium of claim 19, wherein the grouping operator includes an inner block DISTINCT qualifier for the view.
-
26. The computer-readable medium of claim 25, wherein the step of transforming includes the steps of:
-
splitting the outer query block into a first outer query block and a second outer query block, wherein;
the first outer query block encloses said second outer query block, the second outer query block includes a DISTINCT qualifier and contains a WHERE clause of the outer query block and;
migrating the DISTINCT qualifier from the inner query block to the second outer query block; and
merging the inner query block into the second outer query block.
-
-
27. The computer-readable medium of claim 25, wherein the step of transforming includes converting the inner query block into an equivalent inner query block with a GROUP BY clause.
-
28. The computer-readable medium of claim 18, wherein the inner query block includes a subquery.
-
29. The computer-readable medium of claim 28, wherein the subquery is a non-correlated subquery.
-
30. The computer-readable medium of claim 29, wherein the step of transforming includes the step of converting the outer query block into an equivalent outer query block referencing a view based on the non-correlated subquery.
Specification