Journal of the Association for Computing Machinery, Vol. 42, No. 2, March 1995, pp. 329–381.

Decomposition of Magic Rewriting

KE WANG

WEINING ZHANG

AND

SIU-CHEUNG CHAU

Abstract. The magic rewriting focuses on relevant data but suffers from additional rules, predicates, and tuples that are generated in search for the relevant data. Reducing the arity of predicates can cut down the number of such rules, predicates, and tuples by an exponential factor. In this paper, we consider a subclass of linear single-IDB programs and show that the magic rewriting can be decomposed in such a way that it is applied to only programs having smaller arities and fewer recursive rules, without losing the binding capacity. The decomposed rewriting is shown to be much more efficient than the standard one and amenable to distributed and parallel environments. The considered subclass significantly generalizes recursions previously proposed for efficient implementation. The decomposed rewriting and the standard generalized magic rewriting are extended to multibinding queries in such a way that data relevant to one binding is not necessarily considered as relevant to other bindings. The work in this paper shows the use of tuple ID as an important technique in optimizing logic programs.

Categories and Subject Descriptors. F.4.1[logic programming]; H.2.4[query processing]; I.2.3[deduction and logic programming]

General Terms. Algorithms, Theory

Additional Key words and Phrases. Arity reduction, bottom-up evaluation, database, deductive database, logic program, magic rewriting, program decomposition

Copyright 1995 by ACM, Inc. Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or direct commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, to republish, to post on servers, or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from Publications Dept, ACM Inc., fax +1 (212) 869-0481, or permissions@acm.org.