Polystore Query Rewriting: The Challenges of Variety

Yannis PapakonstantinouEDBT/ICDT Workshops 2016

Introduction

In the modern data landscape, organizations increasingly rely on "Polystores"—heterogeneous environments that combine relational (SQL), document-oriented (NoSQL), and NewSQL systems. While this diversity allows for specialized performance across different workloads, it introduces a significant integration challenge known as Variety. This paper addresses the complexities of querying across such systems, arguing that traditional query rewriting techniques are insufficient for the semantic and capability-based differences inherent in polystore architectures.

The Challenge of Variety

Variety in polystores is often misunderstood as a purely syntactic issue (e.g., different keywords). However, the author identifies two deeper levels of variety:

  1. Semantic Variety: Different databases may return different results for the same logical query due to varying treatments of missing attributes, equality, or NULL values.
  2. Capability Variety: Databases have vastly different functional limits. A mediator system might attempt to "push down" a complex filter or join to a source, but if that source (such as an early version of MongoDB) lacks support for nested queries, the execution plan will fail.

The FORWARD Middleware Architecture

To address these challenges, the paper introduces the FORWARD Middleware, a mediator system developed at UCSD. The architecture relies on a unifying query language and a capability-aware rewriting engine to bridge the gap between disparate data sources.

The FORWARD Middleware architecture integrates heterogeneous sources like PostgreSQL and MongoDB through a SQL++ Virtual Database.

SQL++: The Lingua Franca

Central to the FORWARD system is SQL++, a semi-structured query language designed to be backwards-compatible with SQL while natively handling JSON-like data. Rather than hard-coding logic for every possible database, SQL++ utilizes configuration flags. These flags describe a source’s specific capabilities (e.g., "Does it support nested conditions?") and semantic quirks. This allows the language to "morph" its behavior to match the underlying source, ensuring that queries are both valid and semantically consistent.

Capability-Aware Query Rewriting

Traditional federated systems often follow a source-agnostic optimization path, creating a global plan before attempting to decompose it. The authors argue that this approach fails in polystores because there is no single "ideal" plan that works across all sources.

Instead, the FORWARD rewriter is capability-aware from the outset. It analyzes a complex federated query—such as the one shown in Figure 3—and actively seeks to maximize the sub-expressions that can be pushed down to the source databases.

A complex federated query (Q) involving joins and aggregations across sensors and measurements that must be rewritten into source-specific sub-queries.

The rewriter treats the problem as a search for "competitive" plans. It identifies all non-trivially different plans that are valid according to the source capability flags and then passes these candidates to a cost optimizer. This separation of concerns—validity (Rewriter) vs. efficiency (Cost Optimizer)—is a key architectural insight of the paper.

Formalizing Capabilities and Future Work

The paper also explores formal methods for describing source capabilities, such as using Datalog-style parameterized views to determine if a query can be answered by a specific source. While theoretically sound, the authors acknowledge that scaling these formal methods for industrial-strength processors remains a challenge.

Limitations

Several hurdles remain for polystore integration:

  • Cost Estimation: Predicting the fastest plan is difficult when the mediator lacks deep statistics or control over the underlying heterogeneous sources.
  • Data Redundancy: If data is replicated across multiple sources, the number of potential query plans grows exponentially, complicating the optimization process.

Conclusion

This work defines a modular framework for polystore integration that prioritizes capability awareness. By using a configurable language like SQL++, the FORWARD Middleware demonstrates a path toward a practical mediator where the effort to add new data sources grows sublinearly, making the management of data variety more sustainable in large-scale environments.

Summary updated

BibTeX
@inproceedings{papakonstantinou2016polystore,
  author = {Yannis Papakonstantinou},
  title = {{Polystore Query Rewriting: The Challenges of Variety}},
  booktitle = {EDBT/ICDT Workshops},
  year = {2016},
}
Figure