Abstract
Traditional Approximate Query Processing (AQP) methods often rely on data sampling or sketches, which still require significant memory or access to raw data. This paper presents Hunch, a deep learning-based AQP system that treats SQL queries as a language. By training Long Short-Term Memory (LSTM) networks on query-result pairs, Hunch creates a compact (~3MB) model capable of predicting aggregate values with 1-4% error in under 2ms. Hunch decouples query processing from the underlying data size, offering O(1) latency and high throughput for large-scale analytical workloads.
Introduction
The explosion of Big Data has made interactive data analysis increasingly difficult. Standard aggregate queries over billions of records often result in high latency, as systems like Spark or Hadoop typically perform full data scans. While AQP techniques aim to provide fast estimates, they often struggle with memory overhead or the need to maintain raw data access. Hunch addresses this by providing a "data-independent" inference layer that learns data distributions and answers queries without further database access.
Methodology
Hunch utilizes LSTMs to map structured SQL queries to numerical results. The process involves generating synthetic queries from templates, executing them to obtain ground-truth labels, and encoding the queries for the neural network.
Query tokens are multi-hot encoded, while numerical constants in WHERE clauses are converted to binary. The LSTM is then trained to minimize the Mean Squared Error (MSE) of its predictions. To maintain simplicity, complex GROUP BY operations are decomposed into multiple scalar-predicting "flat" queries.
Datasets and Evaluation
The system was evaluated on 12 datasets from the technology industry, including proprietary industrial data and open-source financial records. These datasets ranged in size from thousands of rows to 4 billion rows. This breadth demonstrates Hunch's ability to generalize across different data distributions and scales.
Results and Discussion
Hunch demonstrates significant performance advantages over traditional engines. It achieves a Normalized Root Mean Squared Error (NRMSE) of 1-4%, often outperforming state-of-the-art AQP engines like VerdictDB and BlinkDB.
Key performance metrics include:
- Latency: Single query execution consistently takes less than 2ms. Unlike traditional engines where query time grows with data size, Hunch’s latency is determined only by the complexity of the LSTM.
- Throughput: GPU-accelerated batch processing reaches up to 120,000 queries per second.
- Portability: The 3MB model size allows for deployment on edge devices, enabling offline analytics without a backend database connection.
Conclusion
Hunch represents a paradigm shift in AQP by treating data distribution learning as a language modeling task. While currently limited to single-table aggregates and requiring retraining for data updates, its speed and portability make it a powerful tool for interactive big data exploration. Future work will focus on supporting multi-table joins and incremental learning for dynamic datasets.
Summary updated