A Learned Query Rewrite System using Monte Carlo Tree Search
Xuanhe Zhou, Guoliang Li, Chengliang Chai, Jianhua Feng
摘要
Query rewrite transforms a SQL query into an equivalent one but with higher performance. However, SQL rewrite is an NP-hard problem, and existing approaches adopt heuristics to rewrite the queries. These heuristics have two main limitations. First, the order of applying different rewrite rules significantly affects the query performance. However, the search space of all possible rewrite orders grows exponentially with the number of query operators and rules and it is rather hard to find the optimal rewrite order. Existing methods apply a pre-defined order to rewrite queries and will fall in a local optimum. Second, different rewrite rules have different benefits for different queries. Existing methods work on single plans but cannot effectively estimate the benefits of rewriting a query. To address these challenges, we propose a policy tree based query rewrite framework, where the root is the input query and each node is a rewritten query from its parent. We aim to explore the tree nodes in the policy tree to find the optimal rewrite query. We propose to use Monte Carlo Tree Search to explore the policy tree, which navigates the policy tree to efficiently get the optimal node. Moreover, we propose a learning-based model to estimate the expected performance improvement of each rewritten query, which guides the tree search more accurately. We also propose a parallel algorithm that can explore the tree search in parallel in order to improve the performance. Experimental results showed that our method significantly outperformed existing approaches.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 28 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Adaptive Code Learning for Spark Configuration Tuning 引用了 Query Performance Prediction for Concurrent Queries using Graph Embedding
- Adaptive Code Learning for Spark Configuration Tuning 引用了 An End-to-End Learning-based Cost Estimator
- Adaptive Code Learning for Spark Configuration Tuning 引用了 Reinforcement Learning with Tree-LSTM for Join Order Selection
- Learned Cardinality Estimation: A Design Space Exploration and A Comparative Evaluation 引用了 Query Performance Prediction for Concurrent Queries using Graph Embedding
- Learned Cardinality Estimation: A Design Space Exploration and A Comparative Evaluation 引用了 Deep Unsupervised Cardinality Estimation
- Learned Cardinality Estimation: A Design Space Exploration and A Comparative Evaluation 引用了 An End-to-End Learning-based Cost Estimator
- Learned Cardinality Estimation: A Design Space Exploration and A Comparative Evaluation 引用了 Reinforcement Learning with Tree-LSTM for Join Order Selection
- Query Performance Prediction for Concurrent Queries using Graph Embedding 引用了 An End-to-End Learning-based Cost Estimator
- LLM-R2: A Large Language Model Enhanced Rule-based Rewrite System for Boosting Query Efficiency 引用了 WeTune: Automatic Discovery and Verification of Query Rewrite Rules
- GenRewrite: Query Rewriting via Large Language Models 引用了 LLM-R2: A Large Language Model Enhanced Rule-based Rewrite System for Boosting Query Efficiency
- GenRewrite: Query Rewriting via Large Language Models 引用了 WeTune: Automatic Discovery and Verification of Query Rewrite Rules
- An End-to-End Learning-based Cost Estimator 引用了 Reinforcement Learning with Tree-LSTM for Join Order Selection
- Reinforcement Learning with Tree-LSTM for Join Order Selection 引用了 An End-to-End Learning-based Cost Estimator
- Cost-based or Learning-based? A Hybrid Query Optimizer for Query Plan Selection 引用了 Learned Cardinality Estimation: A Design Space Exploration and A Comparative Evaluation
- Cost-based or Learning-based? A Hybrid Query Optimizer for Query Plan Selection 引用了 Deep Unsupervised Cardinality Estimation
- Cost-based or Learning-based? A Hybrid Query Optimizer for Query Plan Selection 引用了 An End-to-End Learning-based Cost Estimator
- Cost-based or Learning-based? A Hybrid Query Optimizer for Query Plan Selection 引用了 Reinforcement Learning with Tree-LSTM for Join Order Selection
引用它的顶会 Paper28
- Cost-based or Learning-based? A Hybrid Query Optimizer for Query Plan SelectionXiang Yu, Chengliang Chai, Guoliang Li, Jiabin LiuVLDB 2022 · 82 次引用
- LLM-R2: A Large Language Model Enhanced Rule-based Rewrite System for Boosting Query EfficiencyZhaodonghui Li, Haitao Yuan, Huiming Wang, Gao Cong 等VLDB 2025 · 52 次引用
- WeTune: Automatic Discovery and Verification of Query Rewrite RulesZhaoguo Wang, Zhou Zhou, Yicun Yang, Haoran Ding 等SIGMOD 2022 · 35 次引用
- Adaptive Code Learning for Spark Configuration TuningChen Lin, Junqing Zhuang, Jiadong Feng, Hui Li 等ICDE 2022 · 28 次引用
- GenRewrite: Query Rewriting via Large Language ModelsJie Liu, Barzan MozafariSIGMOD 2026 · 27 次引用
它引用的 Paper8
- An End-to-End Learning-based Cost EstimatorJi Sun, Guoliang LiVLDB 2020 · 251 次引用
- Deep Unsupervised Cardinality EstimationZongheng Yang, Eric Liang, Amog Kamsetty, Chenggang Wu 等VLDB 2020 · 206 次引用
- Reinforcement Learning with Tree-LSTM for Join Order SelectionXiang Yu, Guoliang Li, Chengliang Chai, Nan TangICDE 2020 · 168 次引用
- Query Performance Prediction for Concurrent Queries using Graph EmbeddingXuanhe Zhou, Ji Sun, Guoliang Li, Jianhua FengVLDB 2020 · 96 次引用
- Learned Cardinality Estimation: A Design Space Exploration and A Comparative EvaluationJi Sun, Jintao Zhang, Zhaoyan Sun, Guoliang Li 等VLDB 2022 · 90 次引用
相关 Paper
- ReSequel: Robust LLM-assisted Query Rewriting and Optimization using Templatization and SamplingSaeed Fathollahzadeh, Essam Mansour, Matthias BoehmVLDB 2026
- Efficient Query Rewrite Rule Discovery via Standardized Enumeration and Learning-to-RankYuan Zhang, Yuxing Chen, Yuekun Yu, Jinbin Huang 等ICDE 2026
- QueryBooster: Improving SQL Performance Using Middleware Services for Human-Centered Query RewritingQiushi Bai, Sadeem Alsudais, Chen LiVLDB 2023 · 14 次引用
- SlabCity: Whole-Query Optimization using Program SynthesisRui Dong, Jie Liu, Yuxuan Zhu, Cong Yan 等VLDB 2023 · 11 次引用
- ARG: Testing Query Rewriters via Abstract Rule Guided FuzzingDawei Li, Yuxiao Guo, Qifan Liu, Jie Liang 等ASE 2025
