A method of satisfying a database query includes evaluating certain joins
on a per-segment basis. An expression tree is produced for the query, and
the expression tree is evaluated to identify joins whose operands are two
instances of the same relation and whose join predicate conjunctively
includes an equality comparison between two instances of the same column.
When such a join is identified, it may be evaluated by segmenting the
operand relation according to the columns that are compared for equality
in the predicate. The join is then evaluated by performing the join
operation separately on each segment. Segments may be spooled separately,
thereby exploiting the efficiencies obtained by spooling even where the
entire relation is too large to fit in the spool. Execution iterators are
provided for spooling successive segments and for applying the join to
the spooled segment.