Abstract
Conjunctive queries (CQs) are the standard for data retrieval in relational databases, yet their evaluation is generally NP-complete. Acyclicity is a structural property that guarantees linear-time evaluation. This paper investigates semantic acyclicity—a condition where a query, though structurally cyclic, is equivalent to an acyclic query under a set of integrity constraints. We map the boundaries of decidability for this property across various classes of tuple-generating dependencies (tgds), providing a comprehensive complexity landscape.
Introduction
In database theory, the "gold standard" for query performance is acyclicity. Acyclic queries can be evaluated efficiently using algorithms like Yannakakis's. However, many real-world queries are cyclic. Fortunately, databases are often governed by integrity constraints (e.g., foreign key relationships) that restrict the possible states of the data. Semantic acyclicity leverages these constraints to "smooth out" cyclic queries, transforming them into equivalent acyclic forms that run significantly faster.
The central question addressed is: Given a query $Q$ and a set of constraints $\Sigma$, is $Q$ semantically acyclic? That is, does there exist an acyclic query $Q'$ such that $Q \equiv_\Sigma Q'$?
Methodology: The Chase and Structural Preservation
The primary tool for analyzing semantic acyclicity is the chase procedure. The chase symbolically applies constraints to a query, adding new atoms that must exist if the query's conditions are met.
The authors identify two key mechanisms that render semantic acyclicity decidable:
- Acyclicity-Preserving Chase: For certain constraints, such as guarded tgds, the chase process preserves the "tree-like" structure (low treewidth) of the query. If a query can be chased into an acyclic form without losing this property, it is semantically acyclic.
- UCQ Rewritability: For classes like non-recursive or sticky tgds, the problem can be reduced to checking the acyclicity of a finite Union of Conjunctive Queries (UCQ), a task for which established methods exist.
Complexity Results
The paper establishes a rigorous complexity map for determining semantic acyclicity:
- Guarded Tgds: Decidable and 2EXPTIME-complete. The complexity arises from the potential exponential growth of the chase, but the structural preservation ensures it remains within these bounds. For fixed schemas, the complexity drops to NP-complete.
- Non-recursive Tgds: Decidable and NEXPTIME-complete (NP-complete for fixed schemas).
- Sticky Tgds: Decidable, with complexity situated between EXPTIME and NEXPTIME.
- Full Tgds (Datalog-like): Undecidable. The authors use a reduction from the Post Correspondence Problem (PCP) to show that no general algorithm can decide semantic acyclicity for this class.
- Equality-Generating Dependencies (egds): For simple schemas involving unary or binary predicates, the problem is NP-complete.
Discussion and Key Insights
A major takeaway is that semantic acyclicity is strictly harder than the standard query containment problem. While one might expect that deciding if $Q \subseteq_\Sigma Q_{acyclic}$ would be sufficient, the authors prove that the search for any equivalent acyclic query adds a layer of complexity.
Furthermore, the "Guarded Advantage" is highlighted. Guarded dependencies require all variables in a rule's head to appear together in a "guard" atom in the body. This restriction is powerful enough to keep the query's structural properties manageable, making them a "sweet spot" for optimization.
Conclusion
This research demonstrates that integrity constraints are not merely passive data-quality checks but active "accelerators" for query optimization. By identifying the classes of constraints that allow for decidable semantic acyclicity, this work provides a theoretical foundation for building next-generation query optimizers that can automatically simplify complex, cyclic queries into high-performance acyclic ones. Future work remains in tightening the bounds for sticky tgds and extending these results to more general classes of equality-generating dependencies.
Summary updated