NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Enumeration Algorithms for Conjunctive Queries with Projection

Shaleen Deep, Xiao Hu, Paraschos Koutris · DOI

TL;DR

This paper tackles the challenge of efficiently enumerating results for complex database queries (conjunctive queries with projections), aiming to minimize the delay between returning results. The authors introduce novel algorithms that achieve better time-delay tradeoffs than previous methods, particularly for "star" and "path" queries, by cleverly interleaving precomputed data with on-the-fly computation.

What Problem Does This Paper Address?

In database management, efficiently retrieving query results is crucial. While traditional approaches focus on minimizing total query execution time, many applications benefit from a two-phase approach: a preprocessing phase to build an efficient data structure, followed by an enumeration phase that returns results quickly, minimizing the delay between consecutive outputs. This is especially important when users want to see results as soon as possible.

Previous research has established that certain types of queries (acyclic conjunctive queries) can be enumerated with constant delay after linear preprocessing. However, for more complex queries, especially those involving projections (selecting specific columns), the relationship between preprocessing time and enumeration delay is less understood. This paper focuses on finding optimal tradeoffs for "star queries" (queries with a central relation joined to several others) and "path queries" (queries where relations are joined in a chain), aiming to improve upon existing results that offer limited flexibility in this tradeoff.

Methods

The core innovation in this paper is the interleaving of precomputed output with further join processing. Instead of solely relying on precomputed data or purely on-the-fly computation, the algorithms strategically combine both. This allows them to provide results with guaranteed delays even when full precomputation is infeasible or too costly.

Key techniques include:

  • Output-Sensitive Delay Guarantees: Algorithms are designed to provide delay guarantees that depend not only on the input database size but also on the size of the query result itself.
  • Partitioning into "Heavy" and "Light" Tuples: Relations are split based on the "degree" of their values (how many connections they have). Light tuples are handled efficiently with precomputed data, while heavy tuples are processed on-the-fly, interleaved with the light computations.
  • Leveraging Fast Matrix Multiplication: For certain query structures, the authors show how advanced matrix multiplication techniques can be used to achieve better preprocessing time-delay tradeoffs than purely combinatorial approaches.
  • Helper Lemmas for Interleaving: The paper introduces several lemmas that formalize the process of combining results from different algorithms (some with delay guarantees, some without) to achieve a combined, bounded delay. This includes algorithms for merging sorted lists and for deduplicating results.

Datasets

Not discussed in the paper. The paper focuses on theoretical analysis and algorithmic design, using generic database instances and query structures for evaluation.

Key Insights and Ideas

  • Interleaving is Key: The most significant insight is that a hybrid approach, interleaving precomputed results with on-the-fly computation, is crucial for achieving good delay guarantees in complex query scenarios. This allows for flexibility when full precomputation is not an option.
  • Output Size Matters: The delay guarantee is not solely dependent on input size but also on the size of the query's output. This suggests that queries with smaller result sets might allow for faster enumeration.
  • Star Queries Don't Need a Smooth Tradeoff: Unlike general hierarchical queries, star queries exhibit a more distinct tradeoff between preprocessing time and delay, allowing for more specific algorithmic improvements.
  • Matrix Multiplication for Speed: Fast matrix multiplication, while computationally intensive, can offer significant advantages in reducing preprocessing time for certain query structures, leading to better overall tradeoffs.

Key Results

The paper presents several theoretical results, summarized in Figure 1 and Theorem statements:

  • Star Queries: An algorithm is presented that achieves output-dependent delay guarantees for star queries with linear preprocessing time. Specifically, for a star query with $k$ relations, the delay is $O(|D|^{k/(k-1)}/|OUTx|^{1/(k-1)})$, which improves upon prior work, especially when the output size is large.
  • Path Queries: For path queries with $k$ relations, an algorithm achieves a delay of $O(|D|^\epsilon)$ with preprocessing time $O(|D|^{2-\epsilon/(k-1)})$ for any $\epsilon \in [0,1)$. This offers a flexible tradeoff.
  • Algorithmic Improvement: The authors demonstrate instances where their algorithms provide a polynomial improvement in delay compared to existing methods, particularly when the output size is considered.
  • Fast Matrix Multiplication Impact: Using fast matrix multiplication, they achieve better preprocessing time-delay tradeoffs than previously known for certain query types.

Limitations and Future Work

  • More Preprocessing Time for Star Queries: The authors pose the question of whether further improvements in delay can be achieved for star queries if more preprocessing time is allowed.
  • Sublinear Delay for Two-Path Queries: It remains an open question whether sublinear delay can be achieved for two-path queries after linear preprocessing. This is linked to the problem of evaluating $Q_{path}$ in linear time.
  • Space-Delay Bounds: The paper suggests exploring the tradeoff between space and delay for arbitrary hierarchical and path queries, potentially using their interleaving techniques.
  • Dynamic Settings: While some dynamic results are presented (for self-joins), extending these to more general query types remains an area for future work.
  • Non-Self-Join Hardness: The paper highlights that achieving output-sensitive guarantees for non-self-join queries is a non-trivial problem, likely requiring new theoretical machinery.

Summary updated

BibTeX
@article{deep2021enumeration,
  author = {Shaleen Deep and Xiao Hu and Paraschos Koutris},
  title = {{Enumeration Algorithms for Conjunctive Queries with Projection}},
  journal = {Log. Methods Comput. Sci.},
  year = {2021},
  doi = {10.46298/lmcs-21(3:27)2025},
}
Figure