Method and system for using materialized views to evaluate queries involving aggregation
First Claim
1. A method of evaluating a query in a database system including a materialized view, the method comprising the steps of:
- receiving an input query;
semantically analyzing the materialized view to determine whether the materialized view is usable in evaluating the input query;
if the view is usable, rewriting the input query to produce an output query that is multi-set equivalent to the input query, the output query including at least one reference to the materialized view as a source of information to be returned by the output query that was not included in the input query; and
evaluating the output query.
4 Assignments
0 Petitions
Accused Products
Abstract
The present invention is a method and system for using materialized views to compute answers to SQL queries with grouping and aggregation. A query is evaluated a using a materialized view. The materialized view is semantically analyzed to determine whether the materialized view is usable in evaluating an input query. The semantic analysis includes determining that the materialized view does not project out any columns needed to evaluate the input query and determining that the view does not discard any tuple that satisfies a condition enforced in the input query. If the view is usable, the input query is rewritten to produce an output query that is multi-set equivalent to the input query and that specifies one or more occurrences of the materialized view as a source of information to be returned by the output query. The output query is then evaluated. The semantic analysis and rewriting may be iterated, with the output query of each iteration being the input query of the next iteration. The output query is evaluated after the last iteration.
-
Citations
30 Claims
-
1. A method of evaluating a query in a database system including a materialized view, the method comprising the steps of:
-
receiving an input query; semantically analyzing the materialized view to determine whether the materialized view is usable in evaluating the input query; if the view is usable, rewriting the input query to produce an output query that is multi-set equivalent to the input query, the output query including at least one reference to the materialized view as a source of information to be returned by the output query that was not included in the input query; and evaluating the output query. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10)
-
-
11. A system for evaluating a query comprising:
-
a storage device storing a materialized view; a receiver operable to receive an input query; a semantic analyzer operable to analyze the materialized view to determine whether the materialized view is usable in evaluating the input query; a query rewriting device operable to rewrite the input query to produce an output query that is multi-set equivalent to the input query, the output query including at least one reference to the materialized view as a source of information to be returned by the output query that was not included in the input query, if the view is usable; and a query evaluator operable to evaluate the output query. - View Dependent Claims (12, 13, 14, 15, 16, 17, 18, 19, 20)
-
-
21. A computer program storage device, comprising:
-
a computer readable medium embodying computer program instructions for evaluating a query, including; computer program instruction means for receiving an input query; computer program instruction means for semantically analyzing a materialized view to determine whether the materialized view is usable in evaluating the input query; computer program instruction means for rewriting the input query to produce an output query that is multi-set equivalent to the input query, the output query including at least one reference to the materialized view as a source of information to be returned by the output query that was not included in the input query, if the view is usable; and computer program instruction means for evaluating the output query. - View Dependent Claims (22, 23, 24, 25, 26, 27, 28, 29, 30)
-
Specification