Minimizing Conjunctive Regular Path Queries

Diego Figueira, Rémi Morvan, Miguel RomeroarXiv 2025 · DOI

Minimizing Conjunctive Regular Path Queries

Introduction

In graph databases, queries often involve searching for paths defined by regular expressions, known as Conjunctive Regular Path Queries (CRPQs). While the minimization of standard relational Conjunctive Queries (CQs) has been a solved problem since the 1970s—relying on finding the "core" of a query—CRPQs present a significantly harder challenge. The inclusion of regular expressions allows for recursion and potentially infinite path lengths, making it unclear whether finding a minimal equivalent query is even decidable. This research addresses the fundamental question: given a query and a size limit $k$, can we determine if an equivalent query exists with at most $k$ atoms?

Methodology and Structural Analysis

The authors employ distinct algorithmic strategies tailored to the type of query. For single CRPQs, they utilize a brute-force enumeration approach. The key breakthrough is a mathematical proof (Lemma 4.2) demonstrating that if a smaller equivalent query exists, its internal automata components do not need to be infinitely large. By bounding these components to a double-exponential range, the search space becomes finite and the problem decidable.

A critical tool developed for this analysis is the Segment Graph. This abstraction allows researchers to analyze the "skeleton" of a query by grouping labels into segments and representing the connections between variables.

Visualization of query segments and the resulting segment graph used for structural analysis.

For Unions of CRPQs (UCRPQs), the paper introduces Maximal Under-Approximations. Instead of exhaustive searching, the authors construct a "maximal" query of a target size that is guaranteed to be contained within the original. If this approximation is equivalent to the original, a minimal query of that size is confirmed to exist.

Key Insights and Complexity

The study reveals several surprising properties of graph query minimization:

  • Unions as Optimization: A single CRPQ can sometimes be reduced in size if rewritten as a union of multiple smaller queries, making UCRPQ minimization a more potent tool than CRPQ minimization alone.
  • Lack of Canonical Form: Unlike relational queries, CRPQs do not possess a unique "canonical" minimal form; two equivalent minimal queries may appear structurally unrelated.
  • Complexity Bounds: Minimization is exponentially harder than in the relational case. While relational minimization is NP-complete, CRPQ minimization ranges from ExpSpace to 2ExpSpace. However, for "Simple Regular Expressions" (e.g., (a+b)*), the complexity drops to $\Pi^P_2$-complete, suggesting potential for practical implementation.

Results and Future Work

The paper establishes that CRPQ minimization is decidable with a 2ExpSpace upper bound, while UCRPQ minimization is ExpSpace-complete. Variable minimization—reducing the number of nodes in a query—is even more taxing, reaching up to 4ExpSpace.

While these results provide a foundational theoretical framework, the high complexity suggests that general-purpose graph query optimizers are not yet ready for these algorithms. Future research will focus on closing the "Exponential Gap" between lower and upper bounds and identifying further "tractable fragments" of graph queries that allow for efficient minimization in real-world database engines.

Summary updated

BibTeX
@misc{figueira2025minimizing,
  author = {Diego Figueira and Rémi Morvan and Miguel Romero},
  title = {{Minimizing Conjunctive Regular Path Queries}},
  year = {2025},
  eprint = {2504.00612},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.00612},
}
Figure