Abstract
Accurate query cost estimation is critical for resource provisioning and SLA management in large-scale cloud data lakes. However, existing deep learning approaches, such as Tree Convolutional Neural Networks (Tree CNNs), often struggle with the structural diversity of real-world query plans and the high dimensionality of predicates. This paper presents Prestroid, an efficient deep learning pipeline designed for production environments. By introducing sub-tree sampling and learned predicate embeddings, Prestroid reduces memory footprints by 13.5x and training costs by 13.2x while maintaining superior accuracy over state-of-the-art models.
1. Introduction
In modern data-driven enterprises like Grab, managing a 20PB data lake requires precise predictions of CPU consumption for SQL queries. Inaccurate estimations lead to either resource under-provisioning—causing query failures and SLA violations—or over-provisioning, which results in significant financial waste.
While deep learning (DL) models have shown potential in capturing the complex relationships within query plans, two primary bottlenecks hinder their industrial application:
- The Curse of Diversity: Query plans in production vary significantly in size and shape. Standard batch processing on GPUs requires "0-padding" to normalize plan sizes, leading to massive, sparse tensors that exhaust GPU memory.
- Predicate Explosion: Real-world workloads involve tens of thousands of unique filter conditions. Traditional one-hot encoding for these predicates creates high-dimensional vectors that are computationally expensive to manage.
2. The Prestroid Pipeline
Prestroid addresses these challenges through three core innovations designed to handle the scale of a production environment.
2.1 Sub-tree Sampling
To mitigate the overhead of 0-padding, Prestroid employs a sub-tree sampling strategy. Instead of processing a massive, full query plan, the pipeline decomposes the plan into $K$ representative sub-trees, each with a fixed maximum size $N$. This approach ensures that the input tensors are dense and manageable, significantly reducing the GPU memory footprint and allowing for larger batch sizes on more affordable hardware. This suggests that a query's cost can be accurately estimated by looking at representative "chunks" of the plan rather than requiring the entire global structure in a single pass.
2.2 Learned Predicate Embeddings
Rather than relying on sparse one-hot encodings, Prestroid utilizes Word2Vec to generate dense predicate embeddings. By treating columns and operators as "words" within a sequence, the model learns semantic relationships between predicates (e.g., the relationship between "Latitude" and "Longitude"). This dense representation handles "out-of-vocabulary" tokens more effectively and reduces the dimensionality of the input features.
2.3 Tree CNN Architecture
The model utilizes a three-layer Tree Convolutional Neural Network to capture the hierarchical and structural relationships between operators, tables, and predicates. This is followed by dynamic pooling and dense layers to aggregate features and produce the final CPU cost estimate.
3. Experimental Evaluation
The authors evaluated Prestroid using three datasets: Grab-Traces (a production dataset of 245,000 plans), TPC-DS, and TPC-H. Notably, Grab-Traces is significantly more complex than public benchmarks; the largest plan in Grab-Traces contains nearly 5,000 nodes, compared to just 883 in TPC-DS.
3.1 Accuracy and Efficiency
Prestroid outperformed existing models (SVR, MSCN, and WCNN) in accuracy, achieving the lowest Mean Squared Error (MSE) across all datasets. The efficiency gains were even more pronounced:
- Memory Usage: A 13.5x reduction in per-batch memory footprint compared to full-tree models.
- Training Speed: A 3.45x improvement in per-epoch training time.
- Cost-Effectiveness: On Microsoft Azure VMs, the cost to train the model on 19,000 queries dropped from $76.25 to $5.79—a 13.2x reduction for large batch sizes.
4. Discussion and Conclusion
The success of Prestroid demonstrates that technical inefficiencies like 0-padding translate directly into spiraling cloud costs. By optimizing the data structure, the authors moved from requiring high-tier GPUs to being able to train on much cheaper instances. This makes daily retraining feasible—a necessity in fast-growing companies where roughly 12% of tables scanned in a given week are new to the model.
Future work will focus on optimizing implementation bottlenecks (such as TensorFlow's tf_map operator) and extending the model to predict other resource metrics, such as peak memory usage and I/O throughput.
Summary updated