Fast Evaluation of Union-Intersection Expressions

Philip Bille, Anna Pagh, Rasmus Pagh

Abstract

In modern information retrieval and relational database systems, the efficient evaluation of complex set expressions—specifically unions and intersections—is a fundamental bottleneck. Traditional methods, such as merging sorted lists, require time proportional to the total number of elements ($O(n)$). This paper presents a multi-resolution data structure that achieves sub-linear evaluation time by leveraging universal hashing and word-level parallelism. By treating machine words as vectors of hash values, the proposed algorithm achieves a speedup factor approaching the machine word size $w$, providing a nearly optimal solution for static set query processing.

Introduction

Set operations are the core of boolean search queries. When a user searches for multiple terms, the engine must intersect the document sets associated with those terms. While adaptive algorithms can improve performance in specific instances, the worst-case complexity for evaluating an expression over sets with $n$ total elements remains $O(n)$.

The authors of this research investigate whether preprocessing sets into specialized indices can break this linear-time barrier. They propose a framework that utilizes the internal architecture of modern CPUs—specifically the ability to process 64-bit words—to perform "set math" on multiple elements simultaneously. This approach shifts the complexity from the number of elements to a function of the machine word size, effectively enabling sub-linear performance.

The Multi-Resolution Framework

The proposed solution centers on a multi-resolution set representation. This data structure allows the algorithm to trade off between the precision of the set representation and the speed of the bitwise operations. The evaluation follows a three-stage pipeline:

  1. Approximate Evaluation: Elements are mapped to a smaller universe using a universal "mother" hash function. These shortened hash values are small enough that several can be packed into a single machine word. For example, if hash values are 8 bits, a 64-bit word can represent 8 elements.
  2. Word-Level Parallelism: The algorithm performs unions and intersections on these packed words using standard bitwise operations (AND, OR). This mimics SIMD (Single Instruction, Multiple Data) processing within the standard RAM model, allowing the system to process approximately $w/\log w$ elements in a single operation.
  3. Refinement and Verification: Because hashing introduces the possibility of collisions, the approximate stage may produce false positives. The final stage uses a standard hash table to verify these candidates against the original set data, ensuring the final result is exact.

To optimize for different query types, sets are stored at multiple resolutions (varying hash lengths). The algorithm dynamically selects the most efficient resolution based on the sizes of the sets involved in the specific union-intersection expression.

Theoretical Insights and Complexity

The efficiency of this approach relies on the mathematical property of monotonicity. Because union and intersection are monotone operators, if an element $x$ exists in the result of a set expression, its hash $h(x)$ must also exist in the result of the same expression applied to the hashed representations. This ensures that the approximate stage never produces false negatives, only false positives that can be filtered later.

Performance Bounds

For an intersection of $m$ sets containing $n$ total elements, the algorithm achieves an expected running time of: $$O\left(\frac{n(\log w)^2}{w} + km\right)$$ where $k$ is the number of elements in the final result. In scenarios where the word size $w$ is large (e.g., 64-bit or 128-bit architectures), the $n/w$ term dominates, resulting in a speedup of nearly a factor of $w$ over traditional merging techniques.

Optimality

The authors justify the efficiency of their algorithm using multi-party communication complexity, specifically reducing the problem to "Set Disjointness." They provide a cell-probe lower bound demonstrating that their upper bound is nearly optimal for small values of $m$, suggesting that significant further improvements in the RAM model are unlikely.

Limitations and Future Work

While the multi-resolution structure offers significant speedups, it is currently limited to monotone operators. Set difference ($S_1 \setminus S_2$) is not supported because it is non-monotone; a false positive in the approximate representation of $S_2$ could lead to a false negative in the final result, which cannot be easily corrected during the refinement stage.

Additionally, the approach requires a linear-time preprocessing step to build the multi-resolution index. This makes the technique most suitable for static or slowly-evolving datasets, such as web search indices or archival databases, rather than high-velocity streaming data. Future research may focus on extending these sub-linear techniques to non-monotone operations or dynamic data environments.

Summary updated

BibTeX
@inproceedings{bille2007fast,
  author = {Philip Bille and Anna Pagh and Rasmus Pagh},
  title = {{Fast Evaluation of Union-Intersection Expressions}},
  booktitle = {ISAAC},
  year = {2007},
  url = {https://openreview.net/forum?id=3g3EF3-AHF-},
}
Figure