1. A method of optimizing a query in a computer system, the query being performed by the computer system to retrieve data from a database stored on the computer system, the method comprising the steps of: (a) analyzing a query in the computer system using subsumption tests between the query and at least one summary table that comprises a cube index to determine whether an expression in the query can be subsumed by the summary table, wherein the summary table stores at least one materialized view involving at least one GROUP BY operation that computes at least one of the following: (1) a cube, (2) a rollup, (3) a grouping set; and (4) a concatenation of cubes, rollups, grouping sets and one or more grouping items; and (b) when the expression in the query can be subsumed in the summary table, rewriting the query to use the summary table.