Skip to main content
QUICK REVIEW

[Paper Review] Algorithms for Rewriting Aggregate Queries Using Views

Sara Cohen, Werner Nutt|Lirias (KU Leuven)|Nov 17, 2000
Advanced Database Systems and QueriesComputer Science4 citations
TL;DR

This paper presents sound and complete algorithms for rewriting aggregate queries using materialized views, focusing on COUNT and SUM operators. It extends non-aggregate query rewriting techniques—such as the buckets algorithm—by incorporating syntactic characterizations of query equivalence to ensure correctness and completeness in practical database optimization scenarios.

ABSTRACT

Queries involving aggregation are typical in database applications. One of the main ideas to optimize the execution of an aggregate query is to reuse results of previously answered queries. This leads to the problem of rewriting aggregate queries using views. Due to a lack of theory, algorithms for this problem were rather ad-hoc. They were sound, but were not proven to be complete. Recently we have given syntactic characterizations for the equivalence of aggregate queries and applied them to decide when there exist rewritings. However, these decision procedures do not lend themselves immediately to an implementation. In this paper, we present practical algorithms for rewriting queries with $\COUNT$ and $\SUM$. Our algorithms are sound. They are also complete for important cases. Our techniques can be used to improve well-known procedures for rewriting non-aggregate queries. These procedures can then be adapted to obtain algorithms for rewriting queries with $\MIN$ and $\MAX$. The algorithms presented are a basis for realizing optimizers that rewrite queries using views.

Motivation & Objective

  • To address the lack of theoretical foundations in rewriting aggregate queries using materialized views.
  • To develop practical algorithms that are both sound and complete for common aggregate operators like COUNT and SUM.
  • To extend existing non-aggregate query rewriting techniques to handle aggregation, improving efficiency and correctness.
  • To enable efficient query optimization in data warehousing and large-scale database applications by reusing precomputed results.

Proposed method

  • Uses syntactic characterizations of equivalence for aggregate queries (from NSS98 and CNS99) to guide the construction of rewritings.
  • Applies a modified version of the buckets algorithm to non-aggregate views, filtering out views that cannot contribute to valid rewritings.
  • Introduces a homomorphism-based unfolding technique to verify equivalence between candidate rewritings and the original query.
  • Restricts view inclusion in buckets based on variable coverage and consistency, improving performance by reducing the search space.
  • Adapts the approach to handle MAX and MIN queries by reducing equivalence checking to core equivalence of relational queries.
  • Implements the algorithms in SICStus Prolog, demonstrating practical applicability.

Experimental results

Research questions

  • RQ1Can we design algorithms that are both sound and complete for rewriting aggregate queries using views?
  • RQ2How can syntactic characterizations of aggregate query equivalence be used to guide the construction of valid rewritings?
  • RQ3Can existing non-aggregate query rewriting algorithms be enhanced to support aggregation while preserving completeness?
  • RQ4What performance improvements can be achieved by filtering irrelevant views during the rewriting process?
  • RQ5How can the techniques for COUNT and SUM be extended to handle MIN and MAX queries?

Key findings

  • The proposed algorithms are sound and complete for important practical cases, including linear and relational queries.
  • Filtering views based on variable coverage and consistency significantly reduces the number of candidate rewritings, improving algorithm performance.
  • The method enables reuse of precomputed views, reducing the need for full scans of large databases.
  • The approach generalizes well to MAX and MIN queries by reducing equivalence checking to core equivalence of relational queries.
  • The algorithms have been implemented in SICStus Prolog, demonstrating feasibility and practicality in real-world query optimization.
  • The integration of syntactic equivalence checks into the rewriting process ensures correctness without relying on ad-hoc heuristics.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.