Efficient Optimization of Iterative Queries

  • Leonidas Fegaras
Part of the Workshops in Computing book series (WORKSHOPS COMP.)

Abstract

This paper presents a new query algebra based on fold iterations that facilitates database implementation. An algebraic normalization algorithm is introduced that reduces any program expressed in this algebra to a canonical form that generates no intermediate data structures and has no more nested iterations than the initial program. Given any inductive data type, our system can automatically synthesize the definition of the fold operator that traverses instances of this type, and, more importantly, it can produce the necessary transformations for optimizing expressions involving this fold operator.

Database implementation in our framework is controlled by userdefined mappings from abstract types to physical structures. The optimizer uses this information to translate abstract programs and queries into concrete algorithms that conform to the type transformation. Database query optimization can be viewed as a search over the reduced space of all canonical forms which are equivalent to the query after type transformation and normalization. The optimization space can be expanded to capture semantic information expressed as integrity constraints attached to types. This information may include specifications of materialized views and of alternative access paths.

The contribution of this paper is twofold. First, a new efficient algebraic optimization algorithm is introduced, based on loop fusion and partial evaluation, that normalizes a large class of queries over a wide spectrum of bulk data structures. Second, an effective query optimizer is described that searches the limited space of equivalent canonical forms for optimal programs, using additional semantic information to generate more alternatives.

Keywords

Canonical Form Integrity Constraint Query Optimizer Normalization Algorithm Type Transformation 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. [1]
    C. Beeri and Y. Kornatzky. Algebraic Optimization of Object-Oriented Query Languages. In International Conference on Database Theory, Paris, France,pp 72–88. Springer-Verlag, December 1990. LNCS 470.Google Scholar
  2. [2]
    S. Bellantoni and S. Cook. A new Recursion-Theoretic Characterization of the Polynomial Time. In Proceedings of the 24th Annual ACM Symposium on Theory of Computing, Victoria, B.C., pp 283–293, May 1992.Google Scholar
  3. [3]
    V. Breazu-Tannen, P. Buneman, and S. Naqvi. Structural Recursion as a Query Language. In Proceedings of the Third International Workshop on Database Programming Languages: Bulk Types and Persistent Data, Nafplion, Greece, pp 9–19. Morgan Kaufmann Publishers, August 1991.Google Scholar
  4. [4]
    W. Chin. Safe Fusion of Functional Expressions. Proceedings of the ACM Symposium on Lisp and Functional Programming, San Francisco, California, pp 11-20, June 1992.Google Scholar
  5. [5]
    C. Consel and O. Danvy. Tutorial Notes on Partial Evaluation. In Proceedings of the Twentieth ACM Symposium on Principles of Programming Languages, Charleston, South Carolina, pp 493–501, January 1993.Google Scholar
  6. [6]
    J. Darlington and R. Burstall. A System which Automatically Improves Programs. Acta Informatica, 6 (1): 41–60, 1976.MATHCrossRefGoogle Scholar
  7. [7]
    L. Fegaras. A Transformational Approach to Database System Implementation. PhD thesis, Department of Computer Science, University of Massachusetts, Amherst, February 1993. Also appeared as CMPSCI Technical Report 92–68.Google Scholar
  8. [8]
    L. Fegaras, T. Sheard, and D. Stemple. Uniform Traversal Combinators: Definition, Use and Properties. In Proceedings of the 11th International Conference on Automated Deduction (CADE-11), Saratoga Springs, New York, pp 148–162. Springer-Verlag, June 1992. LNCS 607.Google Scholar
  9. [9]
    L. Fegaras and D. Stemple. Using Type Transformation in Database System Implementation. In Proceedings of the Third International Workshop on Database Programming Languages: Bulk Types and Persistent Data, Nafplion, Greece, pp 337–353. Morgan Kaufmann Publishers, August 1991.Google Scholar
  10. [10]
    J. C. Freytag and N. Goodman. On the Translation of Relational Queries into Iterative Programs. ACM Transactions on Database Systems, 14 (1): 127, March 1989.CrossRefGoogle Scholar
  11. [11]
    G. Malcolm. Homomorphisms and Promotability. In Mathematics of Program. Construction, pp 335–347. Springer-Verlag, June 1989. LNCS 375.Google Scholar
  12. [12]
    E. Meijer, M. Fokkinga, and R. Paterson. Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire. In Proceedings of the 5th ACM Conference on Functional Programming Languages and Computer Architecture, Cambridge, MA, pp 124–144, August 1991. LNCS 523.Google Scholar
  13. [13]
    P. Selinger, M. Astrahan, D. Chamberlin, R. Lorie, and T. Price. Access Path Selection in a Relational Database Management System. Proceedings of the ACM-SIGMOD International Conference on Management of Data, Boston, Massachusetts, pp 23–34, May 1979.Google Scholar
  14. [14]
    T. Sheard and L. Fegaras. A Fold for All Seasons. Sixth Conference on Functional Programming Languages and Computer Architecture, Copenhagen, Denmark, pp 233–242, June 1993.Google Scholar
  15. [15]
    S. Shenoy and Z. Ozsoyoglu. Design and Implementation of a Semantic Query Optimizer. ACM Transactions on Knowledge and Data Engineering, 1 (3): 344–361, September 1989.CrossRefGoogle Scholar
  16. [16]
    P. Wadler. Deforestation: Transforming Programs to Eliminate Trees. Proceedings of the 2nd European Symposium on Programming, Nancy, France,pp 344–358, March 1988. LNCS 300.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1994

Authors and Affiliations

  • Leonidas Fegaras
    • 1
  1. 1.Department of Computer Science and EngineeringOregon Graduate Institute of Science & TechnologyPortlandUSA

Personalised recommendations