5. The method of claim 1 , wherein: storing said each materialized view further comprises: determining a set of unique disjuncts from the first one or more disjuncts in the set of aggregate expressions included in the definition of said each materialized view; and storing, in the set of disjunct trees, information that identifies the set of unique disjuncts determined for said each materialized view; and determining the particular materialized view from the plurality of materialized views further comprises: comparing the second one or more disjuncts in the disjunct tree to the set of unique disjuncts determined for said each materialized view of the plurality of materialized views; selecting, in a set of candidate materialized views, all materialized views from the plurality of materialized views that are associated with sets of unique disjuncts that include all of the second one or more disjuncts; for each candidate view of the set of candidate materialized views: generating a canonical form closure that includes expression representations of all combinations of disjuncts in the set of unique disjuncts associated with said each candidate view; and comparing the aggregate expression to the expression representations in the canonical form closure of said each candidate view; and from the set of candidate materialized views, selecting as the particular materialized view a candidate view whose canonical form closure includes an expression representation that matches the aggregate expression.
1. A computer-implemented method for rewriting queries, the method comprising: storing a plurality of materialized views, wherein a definition of each materialized view of the plurality of materialized views includes a set of aggregate expressions, and wherein storing said each materialized view comprises: identifying first one or more disjuncts in the set of aggregate expressions; wherein each of the set of aggregate expressions is an expression that specifies, in the definition of said each materialized view, computation of aggregated data; wherein each of the first one or more disjuncts is an expression block, included within one or more of the set of aggregate expressions, that identifies at least one column and at least one algebraic operator; and generating, based on the first one or more disjuncts, a set of disjunct trees that represent the set of aggregate expressions; storing the set of disjunct trees in computer data storage; receiving a query that requests particular aggregated data, wherein the query comprises an aggregate expression that specifies how the particular aggregated data is to be computed; identifying second one or more disjuncts in the aggregate expression; generating, based on the second one or more disjuncts, a disjunct tree that represents the aggregate expression; based on the disjunct tree and on the set of disjunct trees associated with said each materialized view of the plurality of materialized views, determining a particular materialized view from the plurality of materialized views that stores the particular aggregated data specified by the aggregate expression; and rewriting the query into an equivalent query that references the particular materialized view, wherein the equivalent query when executed would retrieve the particular aggregated data from the particular materialized view; wherein the method is performed by one or more computing devices.