TL;DR
This paper tackles the challenge of accurately estimating the progress of database queries, a crucial task for managing long-running operations. They propose a novel "estimator selection" framework that uses machine learning to dynamically choose the best progress estimator for a given query, significantly improving robustness and accuracy compared to relying on any single existing method.
What Problem Does This Paper Address?
Database systems often execute complex queries that can take a long time to complete. For administrators and users, knowing how far along a query is (its "progress") is vital for making decisions like whether to cancel it, reallocate resources, or simply gauge system performance. While various techniques exist to estimate this progress, none are universally accurate across the wide variety of SQL queries and data distributions encountered in real-world systems. This lack of robustness means that any single estimator will perform poorly for a significant portion of queries, leading to unreliable progress reports. The paper aims to solve this by creating a system that can intelligently select the most appropriate progress estimator on the fly.
Methods
The core of the paper's contribution is an Estimator Selection module. Instead of relying on a single, fixed progress estimation algorithm, this module uses a statistical machine learning approach to choose the best estimator for a given query.
Here's a breakdown of their approach:
- Candidate Estimators: They start with existing progress estimators (DNE, LUO, TGN) and introduce several new "special purpose" estimators designed to handle specific scenarios (e.g., batch operations, index seeks).
- Feature Engineering: The system uses two types of features to inform the selection process:
- Static Features: These are derived from the query's execution plan and initial optimizer estimates before the query starts running. They capture structural properties of the plan and estimated cardinalities.
- Dynamic Features: These are gathered during query execution. They leverage observed runtime behavior, such as the variance in how quickly tuples are processed or how well different estimators' predictions correlate with actual time elapsed.
- Learning Model: They employ Multiple Additive Regression-Trees (MART), a gradient boosting technique, to build regression models. For each candidate estimator, a separate MART model is trained to predict its estimation error. The estimator with the lowest predicted error is then chosen.
- Online Adaptation: The use of dynamic features allows the system to potentially revise its initial estimator choice as the query progresses, further improving accuracy.
Datasets
The paper uses a combination of standard benchmarks and real-world workloads for training and evaluation:
- TPC-H and TPC-DS: These are well-established decision support benchmarks used to generate a large number of queries with varying parameters.
- Real-world Workloads: Two proprietary real-life decision support workloads were also used, characterized by complex queries and large datasets.
They systematically varied parameters like data size, physical database design (tuning levels), and data skew to test the robustness and generalizability of their approach.
Key Insights and Ideas
- No Single Estimator is King: The most fundamental insight is that no single progress estimation algorithm works well for all queries. The paper provides compelling evidence (Figure 1) showing that each existing estimator is optimal for only a subset of queries and can degrade significantly for others.
- Leveraging Machine Learning for Selection: The key innovation is framing progress estimation not as finding one perfect algorithm, but as a selection problem. Machine learning, specifically MART, is well-suited to learn the complex, non-linear relationships between query characteristics and estimator performance.
- The Power of Dynamic Features: While static features provide a good initial guess, dynamic features collected during query execution are crucial for refining the selection. They capture runtime behaviors that are hard to predict beforehand, allowing for more accurate adaptation.
- Generalization is Key: A major focus is on ensuring the learned selection model generalizes to unseen queries and workloads. The paper demonstrates that their approach remains robust even when test data differs significantly from training data.
- Feature Importance: The paper highlights that features related to nested loop joins and the correlation of estimator output with time are particularly important for accurate selection, underscoring the challenges posed by certain query structures.
Key Results
- Significant Robustness Improvement: The estimator selection framework consistently outperformed individual estimators across various sensitivity analyses. For instance, in "ad-hoc" query scenarios (where training and test workloads had no overlap), estimator selection achieved an optimal choice for 55-64% of queries, compared to 31-44% for individual estimators.
- Reduced Estimation Error: The average estimation error (L1 and L2 norms) was substantially lower with estimator selection. In one experiment, the error ratio (estimator error / minimum error) exceeded 5x for only 1% of queries when using dynamic features, compared to 7.8%-14.5% for individual estimators.
- Effectiveness of Novel Estimators: The introduction of specialized estimators (like BATCHDNE and DNESEEK) further improved the performance of the selection framework, especially when combined with dynamic features.
- Low Overhead: The training times for the MART models were very small, even for large training sets, making it feasible to retrain models periodically or adapt them to changing workloads. Feature extraction also has low overhead.
Limitations and Future Work
- Underlying Estimator Quality: The paper acknowledges that the primary source of remaining errors is often the inherent limitations of the available progress estimators themselves, rather than flaws in the selection mechanism.
- Idealized Models: The theoretical "Total GetNext Model" (which assumes perfect cardinality knowledge) shows very low error, suggesting that improving online cardinality refinement techniques could be a significant avenue for future work.
- Specialized Estimators: The authors suggest that developing more specialized progress estimators that address specific query patterns or issues (like partial batches) and integrating them into the selection framework could further boost accuracy.
- Concurrency: The current evaluation assumes queries run in isolation. Extending the framework to handle concurrent query execution and their interactions is noted as an interesting future challenge.
Summary updated