Patent ID: 8209322

Claim:
A machine-implemented method comprising: determining whether a group-by placement technique may be applied to a first query; wherein determining whether the group-by placement technique may be applied to the first query comprises determining whether the first query satisfies a plurality of criteria; wherein the first query satisfies the plurality of criteria if the first query specifies (1) a first table and a second table, (2) a group-by operator, and (3) an aggregation operation on a column of the first table or the second table; applying the group-by placement technique to the first query only in response to determining that the first query satisfies the plurality of criteria, wherein the group-by placement technique cannot be applied if all the plurality of criteria are not satisfied; wherein applying the group-by placement technique to the first query would create a rewritten query that would correspond to the first query and would specify a view instead of the first table or the second table, wherein the view would include a group-by operator; determining whether the view satisfies one or more criteria; and in response to determining that the view satisfies the one or more criteria, transforming the first query into a second query that does not specify the first table and one of the view or the second table; wherein method is performed by one or more computing devices.