Introduction
In the era of Big Data, Approximate Query Processing (AQP) is a critical technique for delivering fast analytical insights. By processing a small random sample of records rather than the entire dataset, AQP can provide estimated results with high accuracy. However, traditional uniform sampling methods face a significant physical limitation: the I/O bottleneck of modern storage hardware.
Modern storage systems, including SSDs and cloud storage like Amazon S3, do not read data record-by-record; they operate on "pages" or "blocks." When performing uniform sampling, even a small 1% sample of records often requires touching nearly 100% of the data pages because the sampled records are scattered throughout the storage medium. This results in data loading times that are nearly identical to those of exact queries, negating the primary benefit of approximation.
The B-AQP Framework
To overcome this bottleneck, we introduce B-AQP, a middleware framework designed to align sampling strategies with physical storage layouts. B-AQP shifts the unit of sampling from individual records to entire data blocks. While this approach is more I/O efficient, it introduces statistical challenges because records within a block are often highly correlated (e.g., sorted by timestamp or category), which can invalidate standard error estimation formulas.
B-AQP addresses these challenges through three core components:
- Block-Oriented Estimation: Instead of treating individual records as independent, B-AQP treats the sum of values within a page as the independent unit. This allows the system to apply the Central Limit Theorem validly, even in the presence of intra-block correlation.
- Two-Stage Pilot Sampling: To meet specific user-defined error targets (e.g., 5% error with 95% confidence), B-AQP first performs a small "pilot" sample. This initial slice is used to estimate block variance, allowing the system to calculate the precise number of additional blocks required to meet the accuracy target.
- Query Rewriting: B-AQP acts as a transparent rewriter, transforming standard SQL queries into versions that utilize native system-level sampling commands (such as
TABLESAMPLE SYSTEM) or specific byte-range requests for cloud storage.
Performance Evaluation
We evaluated B-AQP across several large-scale datasets, including the TPC-H industry benchmark (Scale 5,000), a 1 TB Twitter dataset for ML-based sentiment analysis, and a 1 TB Amazon Reviews dataset for text processing.
As shown in Figure 6, B-AQP delivers massive performance gains. It is up to 185× faster than uniform sampling and up to 12,412× faster than running exact queries. Crucially, B-AQP consistently maintained accuracy within user-defined error bounds across all workloads. For ML-heavy queries, B-AQP reduced data loading from a dominant 64% of total query time to a negligible fraction, ensuring that compute resources like GPUs remained fully utilized.
Conclusion and Future Work
B-AQP demonstrates that aligning algorithmic sampling with physical I/O patterns is essential for high-performance big data analytics. By shifting the statistical unit of analysis to the block level, B-AQP provides rigorous error guarantees while achieving orders-of-magnitude speedups.
Future research will focus on optimizing sample size estimations to reduce the conservativeness of current error bounds, extending the framework to handle complex multi-way joins, and exploring the interaction between block sampling and various data partitioning or sorting strategies.
Summary updated