The tractability frontier of well-designed SPARQL queries

Miguel RomeroPODS 2017 · DOI

Abstract

We study the complexity of query evaluation of SPARQL queries. We focus on the fundamental fragment of well-designed SPARQL restricted to the AND, OPTIONAL and UNION operators. Our main result is a structural characterisation of the classes of well-designed queries that can be evaluated in polynomial time. In particular, we introduce a new notion of width called domination width, which relies on the well-known notion of treewidth. We show that, under some complexity theoretic assumptions, the classes of well-designed queries that can be evaluated in polynomial time are precisely those of bounded domination width.

Introduction

SPARQL serves as the industry-standard language for querying Resource Description Framework (RDF) data, the backbone of the Semantic Web. Despite its importance, evaluating SPARQL queries is computationally expensive, with general evaluation being PSPACE-complete. To address this, researchers often focus on the "well-designed" fragment—a subset using AND, OPTIONAL, and UNION operators in a structured manner to avoid unnatural variable bindings.

Example of SPARQL graph patterns (S, {?x, ?y, ?z}) and (S', {?x, ?y, ?z}) used in the analysis.

Even within this well-designed fragment, evaluation remains coNP-complete. This paper identifies the "tractability frontier" for these queries, providing a complete characterization of which query classes can be evaluated in polynomial time (PTIME). The central question is: what structural properties make a SPARQL query "easy" to solve?

Methodology

The research employs structural graph theory and parameterized complexity to analyze query behavior. The approach is built on several key components:

  1. Pattern Trees and Forests: Queries are represented as "pattern trees," where nodes correspond to basic graph patterns and edges represent the nesting of OPTIONAL operators. This hierarchical view is crucial for analyzing the query's internal dependencies.
  2. Domination Width: The paper's primary innovation is the introduction of domination width. This measure extends the classical concept of treewidth. It determines whether the set of potential solutions for a query can be "dominated" (covered) by a collection of simpler, low-treewidth structures.
  3. Algorithmic Tools: To establish tractability, the author utilizes existential $k$-pebble games to develop a polynomial-time algorithm for queries with bounded domination width.
  4. Hardness Proofs: To prove the "only if" part of the characterization, the author uses the Excluded Grid Theorem. It demonstrates that if a query class has unbounded domination width, its evaluation is $W[1]$-hard, making PTIME evaluation unlikely under standard complexity assumptions.
Pattern trees T1, T2, and T3 representing the hierarchical structure of SPARQL queries.

Key Insights

The introduction of domination width represents a significant breakthrough. It captures the intuition that a query does not need to have low treewidth globally to be tractable; it only needs to be dominatable by low-treewidth components. This insight allows the characterization to surpass "local tractability," the previous standard for SPARQL efficiency.

Furthermore, the paper shows that for queries without the UNION operator, domination width simplifies to "branch treewidth." However, the inclusion of UNION necessitates the more sophisticated domination-based definition to accurately map the tractability frontier.

Results

The study culminates in a definitive dichotomy for well-designed SPARQL queries:

  • The Main Theorem: Assuming $FPT \neq W[1]$, a recursively enumerable class of well-designed SPARQL queries is in PTIME if and only if it has bounded domination width.
  • Complete Classification: This result provides a clear boundary between queries that are efficiently solvable and those that are inherently hard.
  • Sub-fragment Simplification: For the AND-OPTIONAL fragment, the analysis is simplified as domination width becomes equivalent to branch treewidth.

Conclusion and Future Work

While this work provides a complete characterization for the core fragment of SPARQL, several challenges remain. The current study does not include FILTER (constraints) or SELECT (projection) operators. Adding these features complicates the frontier, as the clean "PTIME vs. $W[1]$-hard" split may dissolve into more complex complexity classes.

Additionally, while evaluating low-width queries is efficient, the recognition problem—determining if a given query has low domination width—is itself NP-complete or harder. Future research aims to extend this structural characterization to the full SPARQL language and address the practicalities of query recognition.

Summary updated

BibTeX
@inproceedings{romero2017tractability,
  author = {Miguel Romero},
  title = {{The tractability frontier of well-designed SPARQL queries}},
  booktitle = {PODS},
  year = {2017},
  doi = {10.1145/3196959.3196973},
}
Figure