Model-based Approximate Query Processing

Moritz Kulessa, Alejandro Molina, Carsten Binnig, Benjamin Hilprecht, Kristian KerstingarXiv 2018

Introduction

In the domain of interactive data visualization, latency is a critical factor for user engagement. Research indicates that delays exceeding 500ms disrupt a user's cognitive flow, leading to decreased exploration and fewer insights. As datasets scale into billions of rows, executing exact SQL queries becomes computationally prohibitive for real-time interaction.

The standard mitigation strategy is Approximate Query Processing (AQP), which trades absolute accuracy for significant speedups. However, traditional AQP techniques—such as online and offline sampling—struggle with "rare" subpopulations. Online sampling often misses rare records entirely, leading to high variance and error. Offline sampling requires pre-calculating biased samples, which necessitates prior knowledge of the user's workload—an impractical requirement for ad-hoc exploration.

Methods: Generative Models for AQP

To address these challenges, the authors propose a model-based AQP approach that replaces raw data samples with Mixed Sum-Product Networks (MSPNs). MSPNs are deep generative models that represent joint probability distributions as a hierarchical graph of sum nodes (representing mixtures or subpopulations) and product nodes (representing independent features).

The workflow of model-based AQP, showing the transition from offline model training to online probability-based and sample-based query execution.

The system operates in two distinct phases: an offline phase where a generative model is learned from the database, and an online phase where queries are answered using the model. The authors introduce two primary execution strategies:

  1. Probability-based Strategy: For standard aggregates like COUNT, AVG, and SUM, the system translates SQL queries into probabilistic inference tasks. By traversing the SPN graph, the system calculates results in linear time relative to the model size, bypassing the raw data entirely.
  2. Sample-based Strategy: For complex queries involving user-defined functions (UDFs) or non-linear arithmetic, the SPN generates "biased" samples on-the-fly. Unlike random sampling, the model can be conditioned to generate samples that specifically satisfy rare filter conditions, ensuring high coverage even for small subpopulations.
A Sum-Product Network (SPN) structure illustrating the hierarchical arrangement of sum (+) and product (x) nodes used to represent data distributions.

To further optimize performance, the implementation utilizes marginalization, which allows the system to prune irrelevant branches of the model for specific queries, significantly reducing computation time.

Evaluation and Key Insights

The approach was evaluated using the Flights Dataset (scaled up to 10M rows) and a synthetic dataset designed to test extreme data skewness and query selectivity. Several key insights emerged from this evaluation:

  • Decoupling Performance from Scale: Unlike traditional databases where query time scales with the number of rows, model-based AQP performance depends on the complexity of the model. Answering a query on 100 million rows takes roughly the same time as on 1 million rows once the model is trained.
  • Efficient Compression: The SPN serves as a highly compressed synopsis. For a 10M record dataset, the model occupied only 0.32% of the original data size while maintaining high accuracy.
  • Reliability on Rare Groups: Error rates are primarily determined by the number of instances the model observed during training rather than the total dataset size. Groups with more than 100 representatives in the training set typically yielded highly reliable estimates.

Results

Model-based AQP demonstrated superior accuracy on the "long tail" of queries. In scenarios with low selectivity where random sampling often failed to return any results (zero bin completeness), the SPN provided estimates with low relative error. Furthermore, the probability-based approach was consistently faster than exact SQL by orders of magnitude, particularly as dataset sizes increased.

Limitations and Future Work

While promising, the current framework focuses on single-table queries. Future research aims to extend this to support complex joins and nested queries, potentially through a "one SPN per table" architecture. Additionally, while query execution is rapid, the offline training phase for SPNs can be time-intensive, and the system currently assumes a static analytical workload. Developing methods for incremental model updates and automated hyper-parameter tuning remains a priority for making model-based AQP more robust for dynamic environments.

Summary updated

BibTeX
@misc{kulessa2018model,
  author = {Moritz Kulessa and Alejandro Molina and Carsten Binnig and Benjamin Hilprecht and Kristian Kersting},
  title = {{Model-based Approximate Query Processing}},
  year = {2018},
  eprint = {1811.06224},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1811.06224},
}
Figure