Abstract
Traditional Approximate Query Processing (AQP) techniques often struggle to balance accuracy, flexibility, and performance when handling complex GROUP BY queries on massive, skewed datasets. This paper introduces a novel AQP framework that replaces physical data sampling with a generative approach using Conditional Wasserstein Generative Adversarial Networks (CWGAN). By training a model to synthesize data samples conditioned on specific groups or spatial buckets, the system achieves high accuracy for rare groups and low-selectivity queries. Experimental results demonstrate that this generative approach provides constant-time sampling latency, significantly lower storage requirements than existing model-based AQP methods, and robust performance on datasets exceeding 100 million rows.
Introduction
As datasets grow to petabyte scales, executing exact aggregation queries (e.g., COUNT, AVG, SUM) becomes computationally prohibitive due to massive disk I/O requirements. Approximate Query Processing (AQP) has emerged as a solution, providing fast, near-accurate results by processing only a fraction of the data. However, GROUP BY queries present a significant challenge for standard AQP methods.
Existing techniques generally fall into three categories, each with a distinct drawback:
- Uniform Sampling: Simple to implement but often misses "rare groups" in skewed data, leading to high error rates for the long tail.
- Offline Stratified Sampling: Provides accuracy for rare groups by over-sampling them in advance, but it is rigid; it cannot easily adapt to queries on attributes not included in the original stratification.
- Online Sampling: Offers flexibility by pulling custom samples at query time, but is bottlenecked by the very disk I/O it seeks to avoid.
This paper proposes a generative alternative that bypasses the disk entirely by learning the underlying data distribution and synthesizing samples on demand.
Methodology
Conditional Data Generation
The core of the framework is a Conditional Wasserstein GAN (CWGAN). Unlike standard GANs that learn a general distribution, a CWGAN is conditioned on auxiliary information—in this case, the GROUP BY attribute. During the training phase, each tuple in the database is fed into the model alongside its group label (represented via one-hot encoding).
At query time, the model functions as a "generative sampler." Instead of scanning a table, the system provides the CWGAN with the desired group label and a noise vector. The model then synthesizes $N$ samples that statistically mirror the original data for that specific group. This allows for the immediate generation of a sufficient number of samples even for the rarest groups in the dataset.
Optimizing Sample Allocation
To further reduce estimation error, the framework integrates with optimal allocation algorithms like CVOPT. Because the CWGAN can generate an arbitrary number of samples at virtually no extra cost, the system can calculate the mathematically optimal number of samples to draw for each group based on its variance, ensuring the highest possible global accuracy.
Handling Predicates with Bucket-Conditioning
Queries with WHERE clauses (low-selectivity queries) are traditionally difficult for AQP because most random samples are discarded if they do not meet the filter criteria. To address this, the authors implement Bucket-Conditioned Generation. The data is partitioned into an equi-depth histogram. The CWGAN is then trained to condition on both the group label and the specific spatial bucket. When a query includes a range predicate, the model only generates samples for the buckets that intersect with that range, acting as a generative index that synthesizes only the relevant "needles" in the data haystack.
Experimental Evaluation
Datasets
The framework was evaluated on two primary datasets:
- ROAD: A real-world 3D road network dataset (~434,000 tuples) where latitude was partitioned into 10 groups.
- GAUSS: A synthetic 100-million tuple dataset designed to test extreme skew, featuring four Gaussian distributions of vastly different sizes (ranging from 10M to 40M tuples) and variances.
Performance and Accuracy
- Latency: The CWGAN demonstrated constant-time performance. Generating 1,000 samples took approximately 0.033 seconds regardless of the dataset size. In contrast, traditional random sampling latency increased linearly, exceeding 5 seconds for the 100M tuple GAUSS dataset.
- Accuracy: For low-selectivity queries (selectivity < 0.05), the CWGAN method significantly outperformed both uniform sampling and DBEst (a state-of-the-art model-based AQP tool) in terms of Mean Squared Error (MSE) and Average Relative Error (ARE).
- Storage Efficiency: The trained CWGAN model for the GAUSS dataset required only 77 KB. DBEst, which builds separate models for different groups, required nearly 2 MB to achieve similar modeling quality, highlighting the efficiency of using a single conditional model.
Conclusion and Future Work
By decoupling sampling from disk I/O, the CWGAN-based AQP framework provides a scalable, high-speed solution for complex aggregation queries. It effectively solves the rare-group problem and handles low-selectivity predicates with minimal storage overhead.
Currently, the system relies on discrete histogram buckets to handle continuous range predicates. Future research will focus on evolving the architecture to support continuous conditioning, allowing the model to generate samples for any arbitrary numerical range without the need for pre-defined buckets. Additionally, exploring more complex neural architectures could expand the framework's utility to high-dimensional tabular data with mixed categorical and continuous features.
Summary updated