COOOL: A Learning-To-Rank Approach for SQL Hint Recommendations
Preprint
Abstract
Query optimization is a pivotal part of every database management system (DBMS) since it determines the efficiency of query execution. Numerous works have introduced Machine Learning (ML) techniques to cost modeling, cardinality estimation, and end-to-end learned optimizer, but few of them are proven practical due to long training time, lack of interpretability, and integration cost. A recent study provides a practical method to optimize queries by recommending per-query hints but it suffers from two inherited problems. First, it follows the regression framework to predict the absolute latency of each query plan, which is very challenging because the latencies of query plans for a certain query may span multiple orders of magnitude. Second, it requires training a model for each dataset, which restricts the application of the trained models in practice. In this paper, we propose COOOL to predict Cost Orders of query plans to cOOperate with DBMS by Learning-To-Rank. Instead of estimating absolute costs, COOOL uses ranking-based approaches to compute relative ranking scores of the costs of query plans. We show that COOOL is theoretically valid to distinguish query plans with different latencies. We implement COOOL on PostgreSQL, and extensive experiments on join-order-benchmark and TPC-H data demonstrate that COOOL outperforms PostgreSQL and state-of-the-art methods on single-dataset tasks as well as a unified model for multiple-dataset tasks. Our experiments also shed some light on why COOOL outperforms regression approaches from the representation learning perspective, which may guide future research.Keywords
All Related Versions
This publication has 15 references indexed in Scilit:
- An in-depth study on adversarial learning-to-rankInformation Retrieval Journal, 2023
- Balsa: Learning a Query Optimizer Without Expert Demonstrations2022
- On Feature Decorrelation in Self-Supervised Learning2021
- SkinnerDB: Regret-bounded Query Evaluation via Reinforcement LearningACM Transactions on Database Systems, 2021
- Bao: Making Learned Query Optimization PracticalACM SIGMOD Record, 2021
- NeoProceedings of the VLDB Endowment, 2019
- Query optimization through the looking glass, and what we found running the Join Order BenchmarkThe VLDB Journal, 2017
- Histograms and Wavelets on Probabilistic DataIEEE Transactions on Knowledge and Data Engineering, 2010
- New TPC benchmarks for decision support and web commerceACM SIGMOD Record, 2000
- Implications of certain assumptions in database performance evauationACM Transactions on Database Systems, 1984