Public SPARQL endpoints expose massive knowledge graphs to the web, but they face a fundamental tension between completeness and responsiveness. To prevent expensive, long-running queries from monopolizing server resources—a phenomenon known as the convoy effect—providers enforce strict execution quotas or timeouts. However, abruptly terminating a query leaves users with incomplete data, turning timeouts into hard application failures.
Web preemption resolves this conflict by reframing timeouts from failures into opportunities for progress. Instead of killing a query when its time quantum expires, the server suspends execution, serializes the operational state, and returns partial results alongside a mechanism to resume the work. The client can then request the next batch of results by presenting this saved state, effectively chunking a massive query into a sequence of short, guaranteed-to-terminate steps.
Physical Preemption via Interruptible Iterators
To suspend a running database query without significant performance penalties, the underlying query engine must be able to pause mid-execution and externalize its state. In SaGe: Web Preemption for Public SPARQL Query Services, Thomas Minier et al. introduced an architecture built on interruptible iterators.
In this model, standard query operators (such as joins and scans) are implemented as preemptable iterators that can recursively save and load their internal execution states. When the server's allocated time quantum is reached:
- The engine pauses the active iterator tree.
- The current operator states and intermediate results are serialized into a compact, transferable representation.
- This state is sent back to the client.
When the client wishes to continue, it sends the state token back to the server, which deserializes it and resumes execution exactly where it left off. The authors demonstrated that the overhead for this mechanism is remarkably low—approximately 1ms for suspension and 1.5ms for resumption—consuming only a tiny fraction (~3%) of a typical time quantum.
[Client] --- 1. Submits Query ---> [Preemptable Server]
| (Runs for 50ms Quantum)
[Client] <--- 2. Partial Results + ------+ (Suspends Iterators)
State Token
[Client] --- 3. Resumes with Token ----> [Preemptable Server]
| (Restores Iterators)
v (Continues Execution)
Adapting Complex Operators for Preemption
While basic graph patterns (BGPs) map cleanly to interruptible iterators, more complex relational operations require specialized preemptable operators to avoid redundant computation upon resumption.
Property Path Queries
Property paths allow users to query arbitrary-length paths in a knowledge graph, but their transitive nature makes them highly prone to hitting server quotas. In How to Execute SPARQL Property Path Queries Online and Get Complete Results?, Julien AIMONIER-DAVAT et al. proposed decomposing complex property paths into smaller, guaranteed-to-terminate BGP subqueries. To optimize this natively within the engine, the authors introduced a Partial Transitive Closure (PTC) operator in Processing SPARQL Property Path Queries Online with Web Preemption. The PTC operator tracks the frontier of the graph traversal, allowing the server to suspend and resume path exploration without re-evaluating previously visited nodes or transferring excessive intermediate data.
TOP-k Queries
Traditional query engines process ORDER BY ... LIMIT k queries using a "materialize-and-sort" strategy, which requires computing and sorting the entire result set before returning the top $k$ items. Under strict time limits, this strategy frequently times out before producing any results. In Processing SPARQL TOP-k Queries Online with Web Preemption, Julien AIMONIER-DAVAT et al. designed a preemptable partial TOP-k operator. This operator maintains a bounded priority queue of the best results found so far. When preempted, it saves this partial top-$k$ list alongside the execution cursor. Upon resumption, the operator uses the current bounds to aggressively prune irrelevant parts of the search space, significantly reducing data transfer and overall execution time.
Logical Preemption: Achieving Complete Statelessness
While physical preemption via state tokens is highly efficient, it introduces a practical challenge: the state representation is tightly coupled to the internal implementation of the query engine. This requires specialized client-side libraries and protocols to manage the state tokens.
To overcome this limitation, Thi Hoang Thi PHAM et al. introduced logical query preemption via the PASSAGE framework in Passage: Ensuring Completeness and Responsiveness of Public SPARQL Endpoints with SPARQL Continuation Queries. Instead of serializing low-level physical iterator states into a custom token, the server dynamically rewrites the remaining execution work into a standard, valid SPARQL query string—termed a continuation query.
As detailed by the authors in Continuation Queries: Embracing Timeouts on Public SPARQL Endpoints, this approach shifts the paradigm of web preemption in two major ways:
- Server Statelessness: The execution state is encoded entirely within the text of the continuation query returned to the client. The server retains zero session state, eliminating the memory and scalability bottlenecks associated with tracking active client sessions.
- Universal Compatibility: Because the continuation mechanism is just a standard SPARQL query, any standard-compliant SPARQL client can execute it. Clients can iteratively chain these continuation queries using standard HTTP requests until the entire dataset is retrieved, without needing specialized preemption protocols.
Alternative Applications: Controlled Data Monetization
Beyond fair-use resource allocation, web preemption provides a fine-grained mechanism for data providers to control the rate and structure of data delivery. In Enabling Delayed-Answer Auctions for RDF Knowledge Graphs Monetisation, Hala Skaf-Molli et al. leveraged web preemption to implement Delayed-Answer Auctions (DAA) for knowledge graphs.
By utilizing preemption to intentionally suspend query execution and deliver results in controlled batches, the system can manage the time-to-first-result and subsequent data delivery speeds based on economic incentives. This demonstrates that the ability to cleanly pause and resume queries is not only a technical solution for web-scale responsiveness, but also a foundational primitive for sustainable data monetization.
Key Foundational Work
SaGe: Web Preemption for Public SPARQL Query Services (2019) — contributed 6 concept elements to this direction.
How to Execute SPARQL Property Path Queries Online and Get Complete Results? (2020) — contributed 1 concept elements to this direction.