Patent attributes
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.