TL;DR
This paper introduces DISTILL, a system that significantly speeds up database index tuning by using machine learning to intelligently filter out useless index suggestions and accurately estimate the cost of potential index configurations. This allows for much faster tuning without sacrificing the quality of the recommended indexes, a crucial step for managing large, complex databases, especially in cloud environments.
What Problem Does This Paper Address?
Database index tuning tools are essential for optimizing query performance. However, these tools can be incredibly slow and resource-intensive, especially for large workloads. The primary bottleneck is the sheer number of "what-if" optimizer calls required to estimate the cost of various index configurations. For each potential index and query combination, the database optimizer needs to simulate the query's execution to predict its cost. This process is computationally expensive, consuming over 70% of the tuning time. As database workloads grow and cloud environments demand tuning of millions of databases, this scalability challenge becomes a major hurdle. The paper aims to drastically reduce these costly optimizer calls without compromising the effectiveness of the index tuning process.
Methods
DISTILL tackles the problem in two main stages:
- Index Filtering (Index Filter): The authors observed that many syntactically generated indexes are "spurious" – they offer little to no performance improvement. To address this, they developed a workload-agnostic machine learning model called Index Filter. This model learns patterns from query structure, statistics, and existing index structures to predict whether an index is likely to be beneficial. It leverages signals from the original query plan (before any new indexes are added) to estimate an index's "utility" (potential cost reduction). By filtering out these spurious indexes early, DISTILL significantly reduces the number of configurations that need further evaluation.
- Cost Estimation (Index Cost Model): Even after filtering, many index configurations remain. To estimate their costs efficiently, DISTILL employs workload-specific Index Cost Models. These models are trained on-the-fly during the tuning process. The key idea is that queries within a workload often share templates (e.g., parameterized stored procedures), and explored indexes also exhibit similarities. DISTILL clusters similar queries and trains a dedicated cost model for each cluster. This model then predicts the cost of new (query, configuration) pairs, avoiding expensive optimizer calls. An iterative training procedure is used to efficiently train these models with a minimal number of optimizer calls.
Datasets
The paper evaluates DISTILL on four workloads:
- TPC-H: A standard benchmark for decision support systems.
- TPC-DS: A more complex benchmark for decision support systems.
- DSB: A real customer workload, noted as being more complex with skewed data distributions.
- Real-M: Another real customer workload, also described as complex with skewed data distributions.
The Index Filter model is trained offline using data from three of these workloads to ensure it generalizes to unseen data.
Key Insights and Ideas
- Most "syntactically relevant" indexes are actually useless: The paper quantifies that 50-70% of indexes generated by standard methods offer minimal performance gains, making their evaluation a waste of resources.
- Leveraging existing query plans is key: Instead of making new optimizer calls to evaluate potential indexes, DISTILL cleverly uses information from the original query plans to predict an index's potential impact.
- Workload-specific models are more effective than general ones: While a universal cost model is difficult, training models tailored to groups of similar queries within a specific workload yields much better accuracy and efficiency.
- Iterative, clustered training is efficient: By clustering queries and indexes and incrementally training cost models, DISTILL minimizes the number of expensive optimizer calls needed for training.
- Combining filtering and costing provides synergistic benefits: Using Index Filter first reduces the workload for the Index Cost Models, leading to faster convergence and better overall performance.
Key Results
DISTILL demonstrates significant improvements in tuning time:
- Median reduction in tuning time of 3x and a maximum of 12x compared to state-of-the-art tuning tools like DTA.
- When compared to making optimizer calls for every (query, configuration) pair, DISTILL achieves median reductions of 6x and maximum reductions of 20x in tuning time.
- The recommended indexes from DISTILL are of similar quality to those produced by the baseline methods.
- Index Filter can remove over 70% of spurious indexes with low false negative rates.
- Index Cost Models can be trained with fewer than 50 optimizer calls per template, and inference is 2 orders of magnitude faster than optimizer calls.
Limitations and Future Work
- Assumption of available query plans: DISTILL relies on having access to the physical plans of queries with the existing database design. If these are not available, an initial optimizer call per query is needed, which could be a significant overhead for very large workloads.
- Workload compression: The paper notes that workload compression techniques (which select a subset of queries) are complementary. Combining DISTILL's efficient cost estimation with workload compression could further reduce tuning time.
- Incremental tuning: DISTILL is designed for offline tuning. For scenarios where queries arrive sequentially (online tuning), the accuracy of Index Cost Models might be affected if only a small subset of query templates is available for in-situ training. The authors suggest selecting all instances of a query template together in such scenarios.
- Generalizability of Index Filter: While shown to be effective across different workloads, the paper notes that the Index Filter is trained offline. Further research could explore online adaptation or more dynamic feature engineering.
Summary updated