Database Query Optimization
First Claim
1. A computer-implemented method for efficiently transforming a database query comprising:
- detecting a database query;
in response to;
(a) determining that the database query includes a first sub-query and a second sub-query, wherein the first sub-query and second sub-query are operands for a Union operation, wherein a first result of the first sub-query is associated with a first Group By operation, wherein a second result of the second sub-query is associated with a second Group By operation, and wherein a result of the Union operation is associated with a third Group By operation;
(b) determining that partitioning columns are the same for the first and second Group By operations;
(c) determining that the first and second sub-queries include identical algebraic functions; and
(d) determining that the first Group By operation and first sub-query are not referenced elsewhere in the query; and
transforming the database query into an optimized query, wherein the optimized query does not include the Union operation.
2 Assignments
0 Petitions
Accused Products
Abstract
In some embodiments, a method includes detecting a structured query language (SQL) query. The method can also include determining that the SQL query includes a first sub-query and a second sub-query, wherein the first sub-query and second sub-query are operands for a Union operation, wherein a first result of the first sub-query is associated with a first Group By operation, wherein a second result of the second sub-query is associated with a second Group By operation, and wherein a result of the Union operation is associated with a third Group By operation. The method can also include determining that partitioning columns are the same for the first and second Group By operations; determining that the first and second sub-queries include identical algebraic functions; determining that the first Group By operation and first sub-query are not referenced elsewhere in the SQL query; and transforming the SQL query into an optimized query.
23 Citations
25 Claims
-
1. A computer-implemented method for efficiently transforming a database query comprising:
-
detecting a database query; in response to; (a) determining that the database query includes a first sub-query and a second sub-query, wherein the first sub-query and second sub-query are operands for a Union operation, wherein a first result of the first sub-query is associated with a first Group By operation, wherein a second result of the second sub-query is associated with a second Group By operation, and wherein a result of the Union operation is associated with a third Group By operation; (b) determining that partitioning columns are the same for the first and second Group By operations; (c) determining that the first and second sub-queries include identical algebraic functions; and (d) determining that the first Group By operation and first sub-query are not referenced elsewhere in the query; and transforming the database query into an optimized query, wherein the optimized query does not include the Union operation. - View Dependent Claims (2, 3, 4, 5, 6)
-
-
7. A computer-implemented method for transforming database queries to more efficient forms in a computer system, the method comprising:
-
detecting a database query, wherein the database query includes a Select operator, and the database query includes a Union operator between a first sub-query and a second sub-query, wherein the first sub-query includes a Group By operation over the first sub-query, and wherein the second sub-query includes a Group By operation over the second sub-query, and wherein the database query includes a Group By operation over both the first and second sub-queries; determining that rows of a table in the first sub-query match rows of the table in the second sub-query; determining that the first sub-query and the second sub-query reference identical columns of the table and include identical algebraic functions applied to each column of the table; determining that the first sub-query and the first sub-query'"'"'s Group By are not referenced elsewhere in the database query; transforming the database query to an optimized query, wherein the optimized query does not include the Union operator. - View Dependent Claims (8, 9, 10, 11, 12)
-
-
13. A computer program product for transforming a database queries, the computer program product comprising:
a computer readable storage medium having computer usable program code embodied therewith, the computer usable program code comprising a computer usable program code to detect the database query, wherein the database query includes a Select operator, and the database query includes a Union operator between a first sub-query and a second sub-query, wherein the first sub-query includes a Group By operation over the first sub-query, and wherein the second sub-query includes a Group By operation over the second sub-query, and wherein the database query includes a Group By operation over both the first and second sub-queries; determining that rows of a table in the first sub-query match rows of the table in the second sub-query; determine that the first sub-query and the second sub-query reference identical columns of the table and include identical algebraic functions applied to each column of the table; determine that the first sub-query and the first sub-query'"'"'s Group By are not referenced elsewhere in the database query; transform the database query to an optimized query, wherein the optimized query does not include the Union operator. - View Dependent Claims (14, 15, 16, 17, 18)
-
19. An apparatus comprising:
-
a processor configured to execute instructions for a a database management system; the database management system configured to process database queries, wherein the database management system includes a query transformation unit configured to detect a database query, wherein the database query includes a Select operator, and the database query includes a Union operator between a first sub-query and a second sub-query, wherein the first sub-query includes a Group By operation over the first sub-query, and wherein the second sub-query includes a Group By operation over the second sub-query, and wherein the database query includes a Group By operation over both the first and second sub-queries; determine that rows of a table in the first sub-query match rows of the table in the second sub-query; determine that the first sub-query and the second sub-query reference identical columns of the table and include identical algebraic functions applied to each column of the table; determine that the first sub-query and the first sub-query'"'"'s Group By are not referenced elsewhere in the database query; transform the database query to an optimized query, wherein the optimized query does not include the Union operator. - View Dependent Claims (20, 21, 22, 23, 24, 25)
-
Specification