Proof: Accelerating Approximate Aggregation Queries with Expensive Predicates

Daniel Kang, John Guibas, Peter Bailis, Tatsunori Hashimoto, Yi Sun, Matei ZahariaarXiv 2021

Abstract

Modern data analytics often requires computing aggregates over subsets defined by computationally expensive predicates, such as deep learning models applied to video or sensor data. The ABae framework addresses this by employing a two-stage stratified sampling approach. This paper provides the mathematical foundation for ABae, proving it achieves an optimal error rate of $O(N^{-1})$—matching an "oracle" with perfect knowledge of the data distribution—while ensuring the validity of bootstrap-based confidence intervals.

The Challenge of Expensive Predicates

In standard SQL, a WHERE clause is typically inexpensive. However, in modern applications, the predicate might involve running a heavy computer vision model on thousands of hours of video. To make such queries feasible, systems use Approximate Query Processing (AQP), which samples the data to estimate the final result.

The core challenge is allocating a limited sampling budget $N$ to minimize error. Random sampling is often inefficient, especially when the predicate matches only a small, high-variance portion of the data.

The ABae Framework: Two-Stage Stratified Sampling

ABae (Approximate Bayesian-like estimation) uses a two-stage stratified sampling strategy to optimize budget allocation without prior knowledge of the data's statistics.

  1. Stratification: The dataset $\mathcal{D}$ is partitioned into $K$ strata based on a "proxy model"—a cheap approximation of the expensive oracle predicate.
  2. Stage 1 (Exploration): A small budget $N_1$ is distributed across all strata to estimate the predicate positive rate ($p_k$) and the standard deviation ($\sigma_k$) within each group.
  3. Stage 2 (Exploitation): The remaining budget $N_2$ is allocated using the Neyman Allocation principle, where more samples are directed to strata with higher match rates and higher variance (proportional to $\sqrt{p_k}\sigma_k$).
  4. Estimation: The results from both stages are combined into a final weighted estimate.
Mathematical notation and symbols used in the ABae proof.

Theoretical Results

The primary contribution of this work is the formal proof of ABae's efficiency and reliability.

Optimal Convergence

The authors prove that the Mean Squared Error (MSE) of the ABae estimate decays at a rate of $O(N^{-1})$. Specifically, the error is shown to be: $$MSE \approx O(N_1^{-1} + N_2^{-1} + N_1^{1/2} N_2^{-3/2})$$ When the budget is split appropriately between the exploration and exploitation stages, this simplifies to the theoretical lower bound for any sampling-based approach. This implies that ABae provides a "free lunch": it performs as well as an oracle that knows the data distribution perfectly beforehand.

Bootstrap Validity

For AQP to be useful in production, it must provide reliable confidence intervals. The paper demonstrates that the statistical functional used by ABae is "Hadamard differentiable." This technical property allows the authors to prove that the Bootstrap method—resampling existing samples to estimate error—is asymptotically valid for this two-stage process.

Discussion and Limitations

While ABae offers strong theoretical guarantees, practical implementation faces certain constraints:

  • Small Sample Sizes: In regimes where a stratum receives very few samples (e.g., fewer than 30), the bootstrap may underestimate the true error.
  • Proxy Quality: The $O(N^{-1})$ rate is robust, but the constant factor depends on the proxy model's quality. A better proxy leads to more effective stratification and lower absolute error.
  • Rounding: Since sample counts must be integers, rounding during budget allocation can introduce minor deviations from the theoretical $N_2$ budget.

Summary updated

BibTeX
@misc{kang2021proof,
  author = {Daniel Kang and John Guibas and Peter Bailis and Tatsunori Hashimoto and Yi Sun and Matei Zaharia},
  title = {{Proof: Accelerating Approximate Aggregation Queries with Expensive Predicates}},
  year = {2021},
  eprint = {2107.12525},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2107.12525},
}
Figure