Previous topic  Top  Next topic  Print this Topic

Propagate Constraints


This rewriter propagates constraints like "less" or "greater" topdown through the rule graph. A simple example:

QUERY q1: ?- p(?X) AND ?X < 5.

RULE r1:  p(?X) :- q(?X).

will be rewritten to

QUERY q1: ?- p(?X) AND ?X < 5.

RULE r1:  p(?X) :- q(?X) AND ?X < 5.

Consider the case when you have 1 million tuples in "q" and only one fact is less than 5. Then this rewriter filters out these tuples in r1 and not later in q1. However, if the constraint does not filter out many results then this optimizer might be counter-productive because the "less" builtin is executed twice.