ML-AQP: Query-Driven Approximate Query Processing based on Machine Learning

Fotis Savva, Christos Anagnostopoulos, Peter TriantafillouarXiv 2020

Abstract

ML-AQP introduces a novel "query-driven" approach to approximate query processing (AQP). By training machine learning models on historical query-result pairs rather than raw data samples, the system achieves significant speedups—up to five orders of magnitude—while maintaining a minimal storage footprint. This approach bypasses the latency and monetary costs associated with scanning large datasets in cloud environments, providing sub-500ms response times essential for interactive data exploration.

The Interactivity Challenge in Big Data

In the era of "Big Data," analysts often face a frustrating trade-off: wait minutes for an exact result from a cloud data warehouse (like BigQuery or Redshift) or pay significant costs for high-performance compute clusters. While traditional Approximate Query Processing (AQP) exists to provide faster "good enough" answers, sampling-based methods still require storing and scanning large data samples. In a cloud environment, these scans still incur monetary costs and latency.

Researchers identify an "interactivity constraint"—the idea that for an analyst to remain productive during exploratory data analysis, query responses must arrive in under 500ms. Current cloud-based and sampling-based systems often fail this limit as data scales into the petabytes.

The trade-off between accuracy and speed across different query processing paradigms.

Methods: A Query-Driven Approach

The core innovation of ML-AQP is its query-driven architecture. Instead of looking at the raw data to build a model, it looks at the history of queries (logs). This shifts the paradigm from data-centric modeling to workload-centric modeling.

1. Vectorization and Inference

The system transforms SQL queries into fixed-length "meta-vectors." It represents range predicates (e.g., WHERE age BETWEEN 20 AND 30) as numerical boundaries. This allows the ML model to "see" the query as a point in high-dimensional space. Once a query is parsed and vectorized, it is passed through a model wrapper to generate a predicted result.

The ML-AQP inference pipeline: from SQL query to predicted result via meta-vectors and model wrappers.

2. Learning the Mapping

ML-AQP uses Gradient Boosting Machines (specifically XGBoost and LightGBM) to learn the mapping between these query vectors and their aggregate results (SUM, AVG, COUNT, MIN, MAX). GBMs were chosen for their ability to handle the sparse, high-dimensional input typical of SQL queries.

3. Error Bounds and Drift Detection

Unlike traditional AQP which uses population statistics for confidence intervals, ML-AQP employs Quantile Regression to generate "Prediction Intervals." This provides a probabilistic guarantee without ever touching the raw data. To handle cases where the underlying data changes, the system uses the Kolmogorov-Smirnov (KS) test to detect distribution shifts and trigger automatic retraining.

Key Results and Insights

The authors evaluated ML-AQP using four diverse workloads: TPC-H, Instacart (scaled to 100GB), Chicago Crimes, and Intel Sensor data.

  • Massive Speedups: ML-AQP provided speedups of 7x to 7,200x compared to VerdictDB, a state-of-the-art sampling AQP.
  • Ultra-Low Latency: Mean response times were consistently around 50ms, well below the 500ms interactivity threshold. Even at the 95th percentile, latency stayed under 120ms.
  • Tiny Footprint: For the Instacart dataset, while a 10% sample required 1.8GB of storage, the ML-AQP models and metadata required only 15.5MB—a ~100x reduction.
  • The Cache Analogy: ML-AQP acts as the "L1 Cache" of the data analytics stack. If the model cannot answer a query with high confidence, the system can fall back to a sampling-based engine or the full data warehouse.

Limitations and Future Work

While powerful, ML-AQP faces a "cold start" problem, requiring a warm-up period to observe queries before it can build accurate models. Current implementation also assumes a "fact table" architecture and requires tables to be pre-joined. Future work will explore data augmentation to help models generalize to unseen query patterns more quickly.

Summary updated

BibTeX
@misc{savva2020ml,
  author = {Fotis Savva and Christos Anagnostopoulos and Peter Triantafillou},
  title = {{ML-AQP: Query-Driven Approximate Query Processing based on Machine Learning}},
  year = {2020},
  eprint = {2003.06613},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2003.06613},
}
Figure