Magic Functions: A Technique to Optimize Extended Datalog Recursive Programs

Several methods have been proposed to compile recursive Datalog programs. The most well-known perform a rewriting of rules using MAGIC or PROBLEM predicates in order to push selections before recursion. Rewritten rule systems are generally complex and difficult to translate into optimized relational algebra programs. Moreover, they often generate too many results; thus, the query must be applied to the generated results to eliminate non relevant answers. In this paper, after a survey of the existing compilation techniques which points out their limitations, we develop the magic function method iutroduced in [GardariuDeMaindreville86]. It is based on an understanding of the query as a function which maps columns of a relation to other columns. A query against recursive rules is then translated into a fixpoint functional equation. The resolution of this fixpoint equation using Tarski’s theorem leads to efficient computation of the query answer. In particular, the derived algorithms push selections through recursion, because selections appear as function arguments. They generate only relevant answers to a given query, without redundant data computation. The purpose of this paper is the introduction of a generalized method to obtain and resolve the fixpoint functional equation. The method is general enough to handle non-binary rules, cyclic rules and function symbols. The main advantages of the method are : (1) It directly generates an optimized relational algebra program. (2) It performs a symbolic precomputation which permits rule redundancy elimination. (3) It fully supports function symbols and range queries.

[1]  Georges Gardarin,et al.  Extending a Relational DBMS Towards a Rule-Based System: An Approach Using Predicate Transition Nets , 1989, Foundations of Knowledge Base Management.

[2]  Carlo Zaniolo,et al.  On the implementation of a simple class of logic queries for databases , 1985, PODS.

[3]  Jack Minker,et al.  Logic and Databases: A Deductive Approach , 1984, CSUR.

[4]  Alfred V. Aho,et al.  Universality of data retrieval languages , 1979, POPL.

[5]  Eliezer L. Lozinskii,et al.  Evaluating Queries in Deductive Databases by Generating , 1985, IJCAI.

[6]  Georges Gardarin,et al.  Evaluation of database recursive logic programs as recurrent function series , 1986, SIGMOD '86.

[7]  David Maier,et al.  Magic sets and other strange ways to implement logic programs (extended abstract) , 1985, PODS '86.

[8]  T H Merrett,et al.  Relational Information Systems , 1983 .

[9]  Lawrence J. Henschen,et al.  On compiling queries in recursive first-order databases , 1984, JACM.

[10]  Catriel Beeri,et al.  On the power of magic , 1987, J. Log. Program..

[11]  Laurent Vieille,et al.  Recursive Axioms in Deductive Databases: The Query/Subquery Approach , 1986, Expert Database Conf..

[12]  Georg Gottlob,et al.  Translation and Optimization of Logic Queries: The Algebraic Approach , 1986, VLDB.

[13]  Jeffrey D. Ullman,et al.  Implementation of logical query languages for databases , 1985, TODS.

[14]  A. Tarski A LATTICE-THEORETICAL FIXPOINT THEOREM AND ITS APPLICATIONS , 1955 .

[15]  Michael Kifer,et al.  Implementing logic programs as a database system , 1987, 1987 IEEE Third International Conference on Data Engineering.

[16]  Chin-Liang Chang On Evaluation of Queries Containing Derived Relations in a Relational Data Base , 1979, Advances in Data Base Theory.

[17]  David Harel,et al.  Horn clauses and the fixpoint query hierarchy , 1982, PODS.