TL;DR
LAQP is a novel Approximate Query Processing (AQP) system that combines random sampling, pre-computed aggregations, and machine learning to deliver fast, highly accurate query results on big data. By using a regression model to predict the sampling error of new queries, LAQP identifies the best historical query to use as a baseline, achieving higher accuracy than existing methods while maintaining strict statistical error guarantees.
What Problem Does This Paper Address?
Running exact queries on massive datasets takes too long for real-time analytics and decision-making. Approximate Query Processing (AQP) solves this by trading a little bit of accuracy for a massive speedup. However, existing AQP methods all have significant trade-offs:
- Random Sampling struggles with highly skewed data and requires large sample sizes to be accurate.
- Pre-aggregation (Data Cubes) scales poorly to high-dimensional data and only supports limited query types.
- Machine Learning (ML) approaches are highly accurate but act as "black boxes." They cannot provide a priori statistical error guarantees (i.e., you don't know mathematically how wrong the answer might be), which is a dealbreaker for many enterprise applications.
The authors aim to build a "best of all worlds" AQP system: one that is highly accurate, requires very little memory, supports general queries, and provides mathematically provable error bounds.
Methods
Instead of using ML to directly predict the answer to a query, LAQP uses ML to predict the error of a fast, simple sampling-based estimate.
Here is how the pipeline works:
- Small Offline Sample: LAQP keeps a very small, static random sample of the dataset in memory.
- Training an Error Model: The system looks at a log of historical queries where the exact answers are known. It estimates the answers to these old queries using the small sample. The difference between the exact answer and the sample estimate is the "sampling error." A Random Forest regression model is then trained to map query predicates (the
WHEREclauses) to their sampling errors. - Query Estimation: When a new query arrives, LAQP uses the ML model to predict its sampling error. It then searches the historical log for an "error-similar" query—an old query whose actual sampling error closely matches the predicted error of the new query.
- Final Calculation: The final answer is computed algebraically:
Exact answer of the old query + Sample estimate of the new query - Sample estimate of the old query.
The authors also introduce extensions to optimize this process, including a diversification strategy (to ensure the historical query log covers a wide variety of errors) and a weighted optimization function that considers both "error similarity" and "range similarity" when picking the best baseline query.
Datasets
The authors evaluated LAQP on three real-world datasets:
- POWER: Individual household electric power consumption data (2 million tuples, 7 numerical attributes). Features a long-tailed distribution.
- WESAD: Wearable Stress and Affect Detection dataset (63 million records, 8 attributes). Features a roughly normal distribution.
- PM2.5: US Embassy Beijing PM2.5 data (43,824 instances). Used specifically to benchmark against DBEst (a competing ML-based AQP method that only supported 1D queries in its implementation).
Key Insights and Ideas
- Error-similarity beats range-similarity: Previous hybrid methods (like AQP++) tried to find historical queries that logically overlapped with the new query (e.g., similar data ranges). LAQP shows that finding queries that behave similarly on a specific random sample (error-similarity) yields much tighter approximations. This is especially true in high-dimensional data, where finding overlapping query ranges is mathematically improbable.
- Having your cake and eating it too: By using ML only to select the best baseline query, and relying on standard sampling to compute the actual difference, LAQP retains statistical error bounds (like Chernoff bounds). This bridges the gap between the high accuracy of modern ML and the strict mathematical guarantees required by traditional database systems.
- Rescuing MIN/MAX queries: Standard sampling is notoriously bad at
MINandMAXqueries because random samples easily miss extreme outliers. Because LAQP anchors its estimate to an exact historical query, it can actually provide highly accurateMIN/MAXestimates if a good baseline query exists in the log.
Key Results
- Superior Accuracy: LAQP significantly outperformed standard sampling (SAQP), pre-aggregation (AQP++), and pure ML (DBEst) in Mean Squared Error (MSE) and Average Relative Error (ARE), particularly when the sample size was heavily restricted (e.g., 0.1% to 1% sampling rates).
- High-Dimensional Robustness: As query dimensions increased (up to 7D on the POWER dataset), competing methods degraded because they couldn't find overlapping queries. LAQP maintained high accuracy because the Random Forest model easily handled multi-dimensional inputs to find error-similar baselines.
- Efficiency: Query processing time is on par with existing methods (under 0.01 seconds). It is slightly slower than pure sampling (because it evaluates both the new query and the baseline query on the sample), but the accuracy gains heavily outweigh the fractional millisecond cost.
- Low Space Cost: LAQP achieves lower error rates than competitors even when constrained to very tight memory budgets (e.g., under 500 KB for the sample, model, and query log combined).
Limitations and Future Work
- Reliance on Query Logs: The system currently requires a pre-existing log of queries with exact answers to train the error model. If a database is entirely new and has no historical workload, LAQP cannot be immediately deployed.
- Future Work: The authors plan to address the above limitation by exploring ways to automatically generate pre-computed synopses and synthetic queries to train the error model, removing the strict dependency on historical query logs.
- Abundant Space Scenario: The authors note that if memory is virtually unlimited (allowing for massive sample sizes and exhaustive pre-computed query logs), the complex overhead of LAQP's error model may not provide a significant advantage over simpler methods.
Summary updated