LearnedSQLGen: Constraint-aware SQL Generation using Reinforcement Learning
Lixi Zhang, Chengliang Chai, Xuanhe Zhou, Guoliang Li
摘要
Many database optimization problems, e.g., slow SQL diagnosis, database testing, optimizer tuning, require a large volume of SQL queries. Due to privacy issues, it is hard to obtain real SQL queries, and thus SQL generation is a very important task in database optimization. Existing SQL generation methods either randomly generate SQL queries or rely on human-crafted SQL templates to generate SQL queries, but they cannot meet various user specific requirements, e.g., slow SQL queries, SQL queries with large result sizes. To address this problem, this paper studies the problem of constraintaware SQL generation, which, given a constraint (e.g., cardinality within [1k,2k]), generates SQL queries satisfying the constraint. This problem is rather challenging, because it is rather hard to capture the relationship from query constraint (e.g., cardinality and cost) to SQL queries and thus it is hard to guide a generation method to explore the SQL generation direction towards meeting the constraint. To address this challenge, we propose a reinforcement learning (RL) based framework LearnedSQLGen, for generating queries satisfying the constraint. LearnedSQLGen adopts an exploration-exploitation strategy that exploits the generation direction following the query constraint, which is learned from query execution feedback. We judiciously design the reward function in RL to guide the generation process accurately. We also integrate a finite-state machine in our model to generate valid SQL queries. Experimental results on three benchmarks showed that LearnedSQLGen significantly outperformed the baselines in terms of both accuracy (30% better) and efficiency (10-35×).
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 10 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- AutoCE: An Accurate and Efficient Model Advisor for Learned Cardinality Estimation 引用了 Reinforcement Learning with Tree-LSTM for Join Order Selection
- AutoCE: An Accurate and Efficient Model Advisor for Learned Cardinality Estimation 引用了 Cardinality Estimation in DBMS: A Comprehensive Benchmark Evaluation
- AutoCE: An Accurate and Efficient Model Advisor for Learned Cardinality Estimation 引用了 Cost-based or Learning-based? A Hybrid Query Optimizer for Query Plan Selection
- ALEX: An Updatable Adaptive Learned Index 引用了 Learning Multi-Dimensional Indexes
- Learning Multi-Dimensional Indexes 引用了 ALEX: An Updatable Adaptive Learned Index
- WISK: A Workload-aware Learned Index for Spatial Keyword Queries 引用了 ALEX: An Updatable Adaptive Learned Index
- WISK: A Workload-aware Learned Index for Spatial Keyword Queries 引用了 Learning Multi-Dimensional Indexes
- Grep: A Graph Learning Based Database Partitioning System 引用了 Reinforcement Learning with Tree-LSTM for Join Order Selection
- Grep: A Graph Learning Based Database Partitioning System 引用了 Cost-based or Learning-based? A Hybrid Query Optimizer for Query Plan Selection
- Cost-based or Learning-based? A Hybrid Query Optimizer for Query Plan Selection 引用了 Reinforcement Learning with Tree-LSTM for Join Order Selection
- Breaking It Down: An In-depth Study of Index Advisors 引用了 Cardinality Estimation in DBMS: A Comprehensive Benchmark Evaluation
引用它的顶会 Paper10
- Cost-based or Learning-based? A Hybrid Query Optimizer for Query Plan SelectionXiang Yu, Chengliang Chai, Guoliang Li, Jiabin LiuVLDB 2022 · 82 次引用
- WISK: A Workload-aware Learned Index for Spatial Keyword QueriesYufan Sheng, Xin Cao, Yixiang Fang, Kaiqi Zhao 等SIGMOD 2023 · 24 次引用
- Breaking It Down: An In-depth Study of Index AdvisorsWei Zhou, Chen Lin, Xuanhe Zhou, Guoliang LiVLDB 2024 · 21 次引用
- Grep: A Graph Learning Based Database Partitioning SystemXuanhe Zhou, Guoliang Li, Jianhua Feng, Luyang Liu 等SIGMOD 2023 · 14 次引用
- AutoCE: An Accurate and Efficient Model Advisor for Learned Cardinality EstimationJintao Zhang, Chao Zhang, Guoliang Li, Chengliang ChaiICDE 2023 · 13 次引用
它引用的 Paper17
- ALEX: An Updatable Adaptive Learned IndexJialin Ding, Umar Farooq Minhas, Jia Yu, Chi Wang 等SIGMOD 2020 · 274 次引用
- Learning Multi-Dimensional IndexesVikram Nathan, Jialin Ding, Mohammad Alizadeh, Tim KraskaSIGMOD 2020 · 180 次引用
- Cardinality Estimation in DBMS: A Comprehensive Benchmark EvaluationYuxing Han, Ziniu Wu, Peizhi Wu, Rong Zhu 等VLDB 2022 · 169 次引用
- Reinforcement Learning with Tree-LSTM for Join Order SelectionXiang Yu, Guoliang Li, Chengliang Chai, Nan TangICDE 2020 · 168 次引用
- An Inquiry into Machine Learning-based Automatic Configuration Tuning Services on Real-World Database Management SystemsDana Van Aken, Dongsheng Yang, Sebastien Brillard, Ari Fiorino 等VLDB 2021 · 108 次引用
相关 Paper
- EXPO-SQL: Execution-based Clause-level Policy Optimization for Text-to-SQLJaehoon Lee, CheolWon Na, Suyoung Bae, Jin-Seop Lee 等ACL Findings 2026 · 1 次引用
- LOGER: A Learned Optimizer towards Generating Efficient and Robust Query Execution PlansTianyi Chen, Jun Gao, Hedui Chen, Yaofeng TuVLDB 2023 · 54 次引用
- Balsa: Learning a Query Optimizer Without Expert DemonstrationsZongheng Yang, Wei-Lin Chiang, Sifei Luan, Gautam Mittal 等SIGMOD 2022 · 99 次引用
- SQL-R1: Training Natural Language to SQL Reasoning Model By Reinforcement LearningPeixian Ma, Xialie Zhuang, Chengjin Xu, Xuhui Jiang 等NeurIPS 2025 · 94 次引用
- FOSS: A Self-Learned Doctor for Query OptimizerKai Zhong, Luming Sun, Tao Ji, Cuiping Li 等ICDE 2024 · 5 次引用
