TL;DR
This paper introduces "Stage," a novel hierarchical query execution time predictor for Amazon Redshift. By combining a cache, an instance-specific model, and a global model, Stage significantly improves query latency and prediction accuracy, outperforming Redshift's previous predictor by 20%.
What Problem Does This Paper Address?
Modern cloud data warehouses like Amazon Redshift rely heavily on accurate query execution time (exec-time) predictions for critical operations such as query optimization, admission control, and resource scheduling. However, existing prediction techniques often struggle with "cold start" issues (new instances with no historical data), inaccurate estimations, and a lack of robustness when workloads or data change. Furthermore, many advanced prediction models have inference latencies that are too high for the fast-executing queries common in Redshift, making them impractical for real-time decision-making on the critical path of query execution.
Methods
The core innovation is the "Stage" predictor, a hierarchical system designed to balance accuracy, robustness, and low inference latency. It comprises three components:
- Exec-time Cache: This is the first line of defense. It stores the actual execution times of recently seen queries. If an incoming query matches a cached entry, its prediction is returned instantly with near-zero latency. This leverages the observation that many queries in Redshift are repetitive.
- Local Model: If a query isn't in the cache, it's passed to a lightweight, instance-optimized model. This model uses a Bayesian ensemble of XGBoost models to predict exec-time and, crucially, provides an uncertainty measure. This model is trained on historical data from a specific Redshift instance.
- Global Model: If the local model is uncertain about its prediction (indicating a potentially long-running or novel query), the query is sent to a complex, transferable global model. This model is a graph convolutional network (GCN) trained across a diverse set of Redshift instances, allowing it to generalize to unseen workloads and instances.
The system is designed to use the most efficient model first, escalating to more complex (and potentially more accurate but slower) models only when necessary, thus amortizing the cost of expensive models.
Datasets
The experiments were conducted using real-world query logs from the top 100 most-billed Amazon Redshift instances across three regions ('us-east-1', 'us-west-2', and 'eu-west-1'). This dataset comprised approximately 30 million queries collected over a two-week period. For training the global model, a subset of 100 instances and three weeks of query data were used, ensuring no overlap with the evaluation instances.
Key Insights and Ideas
- Hierarchy is Key: The paper strongly advocates for a hierarchical approach to query execution time prediction, especially in production systems where latency is paramount. This allows for the use of fast, simple models for common cases and more sophisticated models only when truly needed.
- Uncertainty is Crucial: The local model's ability to quantify its prediction uncertainty is vital. This uncertainty measure acts as a gatekeeper, deciding when to escalate to the more powerful but slower global model.
- Instance-Specific vs. Global Models: The study highlights a tension: while global models trained on vast datasets offer broad applicability, instance-specific models can achieve better accuracy for individual workloads, especially for longer-running queries. This suggests that "more data" doesn't always beat "more relevant data."
- Practicality Over Raw Accuracy: For many Redshift queries, the inference latency of state-of-the-art prediction models is prohibitively high. The Stage predictor prioritizes practical integration by ensuring that expensive models are used sparingly.
- Repetitive Queries are a Goldmine: The high percentage of repeated queries in Redshift makes a caching mechanism incredibly effective, providing near-instant predictions for a significant portion of workloads.
Key Results
- End-to-End Latency Improvement: The Stage predictor improved average query execution latency by 20% compared to Redshift's prior AutoWLM predictor.
- Prediction Accuracy: Stage achieved more than 2x better prediction accuracy (measured by Mean Absolute Error) than the AutoWLM predictor.
- Cache Hit Rate: Approximately 60% of queries found a match in the exec-time cache, allowing for near-instant predictions.
- Model Performance: The local model showed better performance than the global model on average, particularly for long-running queries, suggesting the value of instance-specific tuning.
- Uncertainty Reliability: The local model's uncertainty measurement was found to be reliable, with a median Prediction Rejection Ratio (PRR) score of 0.9, indicating a strong correlation between predicted uncertainty and actual prediction error.
Limitations and Future Work
- Global Model vs. Instance-Specific: The global model, while transferable, did not consistently outperform the local model, especially on long-running queries. The authors suggest that instance-specific characteristics might be crucial and that global models might need to incorporate more database-specific features.
- Long-Running Query Prediction: Both Stage and AutoWLM struggled with predicting very long-running queries (over 60s), possibly due to inherent label noise (variance in execution times for the same query) and sparsity in training data.
- Environmental Factors: The paper acknowledges that external factors like system load, cache state, and buffer pool status significantly impact query execution times but are not currently incorporated into the Stage predictor. Future work could focus on integrating these dynamic environmental factors.
- Improving Global Model: The authors are exploring more robust global models, especially after observing some regressions in its accuracy.
- "What-If" Scenarios: The Stage predictor's global model shows promise for answering hypothetical "what-if" questions (e.g., impact of adding an index), which is a significant area for future research.
- Applying to Other Tasks: The hierarchical prediction framework could be adapted for other critical database tasks like query optimization and cardinality estimation.
Summary updated