Abstract
Approximate Query Processing (AQP) is a critical technique for maintaining interactive analytics on massive datasets by trading a degree of precision for significant gains in execution speed. Traditional AQP approaches, including data sampling and machine learning models, often struggle with complex join predicates and fail to account for the inherent correlations between multiple aggregate functions within a single query. This paper presents GRELA (Graph REpresentation Learning-based AQP), a novel framework that treats the relationship between query predicates and aggregate tasks as a heterogeneous graph problem. By utilizing an attention-based encoder and a graph-based message-passing module, GRELA captures implicit data distributions and inter-task dependencies. Evaluation across diverse benchmarks demonstrates that GRELA achieves superior accuracy and robustness compared to existing state-of-the-art methods while maintaining sub-11ms latency.
Introduction
The computational cost of finding exact answers to aggregate queries (such as SUM, AVG, or COUNT) on massive datasets often precludes interactive data exploration. AQP addresses this by providing fast, approximate results. However, existing AQP methods—sampling, sketches, and standard machine learning—face significant challenges. Sampling is sensitive to outliers, sketches are often limited to specific functions, and many ML models fail to capture the complex relationships between underlying data distributions and query clauses involving multiple joins.
A key observation motivating this work is that aggregate functions in a single query are rarely independent. For instance, knowing the SUM of a column provides a strong signal for its COUNT or MAX. Most existing models treat these as independent tasks, missing an opportunity for improved estimation accuracy by ignoring these implicit correlations.
Methodology
GRELA introduces a two-stage architecture designed to featurize queries and model their internal dependencies through graph representation learning.
1. Encoder Module
This module maps query clauses (the FROM and WHERE components) and underlying data (represented via histograms) into high-dimensional clause embeddings ($x_i$). It employs two specialized attention-based sub-modules:
- S-Transformer: Learns joint attribute distributions from marginal histograms.
- Q-Transformer: Integrates join predicates directly into the data representation.
2. Graph Module
The core of GRELA is a heterogeneous graph where "clause nodes" represent query predicates and "task nodes" represent specific aggregate functions. Through an attention-based message-passing mechanism, task nodes aggregate information from both related query clauses and other task nodes. This structure allows the model to exploit inter-task correlations explicitly. To ensure stability and generalization, GRELA uses weight-tied attention layers to reach an equilibrium state for node embeddings.
The final estimate is derived from the inner product of the clause embedding and the updated task embedding, treating query predicates and aggregate tasks as dual entities in the latent space.
Evaluation
The authors evaluated GRELA on three diverse benchmarks: STATS (Stack Exchange data with complex many-to-many joins), Job-light (IMDB subset), and TPCH (industry standard 100GB benchmark).
Key results include:
- Accuracy: On the STATS dataset, GRELA achieved a relative error of 2.40 at the 90th percentile, significantly outperforming competitors like UniSamp and DeepDB, which often produced errors several orders of magnitude higher or failed on complex joins.
- Efficiency: GRELA maintained an average estimation latency of less than 11ms across all datasets, making it suitable for truly interactive applications.
- Robustness: The model proved resilient to dynamic workloads, including insert-heavy scenarios and distribution shifts, where traditional sampling methods typically degrade.
Conclusion
GRELA demonstrates the power of graph representation learning in AQP by explicitly modeling the correlations between aggregate tasks. By treating aggregate functions as learnable entities within a graph, it achieves state-of-the-art accuracy on complex join queries. Future work will focus on expanding SQL coverage to include LIKE predicates and sub-queries, as well as exploring hybrid execution models that combine ML estimates with exact processing for high-risk queries.
Summary updated