LLM-R2: A Large Language Model Enhanced Rule-based Rewrite System for Boosting Query Efficiency
Zhaodonghui Li, Haitao Yuan, Huiming Wang, Gao Cong, Lidong Bing
摘要
Query rewrite, which aims to improve query efficiency by altering an SQL query's structure without changing its result, has been an important research problem. In order to maintain equivalence between the rewritten query and the original one during rewriting, traditional query rewrite methods always rewrite the queries following certain rewrite rules. However, some problems still remain. First, existing methods of finding the optimal choice or sequence of rewrite rules are still limited and the process always costs a lot of resources. Methods involving discovering new rewrite rules typically require complicated proofs of structural logic or extensive user interactions. Second, current query rewrite methods usually rely highly on DBMS cost estimators which are often not accurate. In this paper, we address these problems by proposing a novel query rewrite method named LLM-R 2 , which leverages a large language model (LLM) to recommend rewrite rules for a database rewrite system. To further enhance the inference ability of the LLM in recommending rewrite rules, we train a contrastive model using a curriculum-based approach to learn query representations and select effective query demonstrations for the LLM. Experimental results show that our method significantly improves the query execution efficiency and outperforms the baseline methods. In addition, our method exhibits high robustness across different datasets.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 22 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- ArchRAG: Attributed Community-based Hierarchical Retrieval-Augmented Generation 引用了 Toolformer: Language Models Can Teach Themselves to Use Tools
- ArchRAG: Attributed Community-based Hierarchical Retrieval-Augmented Generation 引用了 Language Models are Few-Shot Learners
- In-depth Analysis of Graph-based RAG in a Unified Framework 引用了 Toolformer: Language Models Can Teach Themselves to Use Tools
- In-depth Analysis of Graph-based RAG in a Unified Framework 引用了 Language Models are Few-Shot Learners
- Cracking SQL Barriers: An LLM-based Dialect Translation System 引用了 GenRewrite: Query Rewriting via Large Language Models
- Cracking SQL Barriers: An LLM-based Dialect Translation System 引用了 A Learned Query Rewrite System using Monte Carlo Tree Search
- GenRewrite: Query Rewriting via Large Language Models 引用了 A Learned Query Rewrite System using Monte Carlo Tree Search
引用它的顶会 Paper22
- In-depth Analysis of Graph-based RAG in a Unified FrameworkYingli Zhou, Yaodong Su, Youran Sun, Shu Wang 等VLDB 2025 · 48 次引用
- GenRewrite: Query Rewriting via Large Language ModelsJie Liu, Barzan MozafariSIGMOD 2026 · 27 次引用
- ArchRAG: Attributed Community-based Hierarchical Retrieval-Augmented GenerationShu Wang, Yixiang Fang, Yingli Zhou, Xilin Liu 等AAAI 2026 · 23 次引用
- Cracking SQL Barriers: An LLM-based Dialect Translation SystemWei Zhou, Yuyang Gao, Xuanhe Zhou, Guoliang LiSIGMOD 2025 · 14 次引用
- SQLBarber: A System Leveraging Large Language Models to Generate Customized and Realistic SQL WorkloadsJiale Lao, Immanuel TrummerSIGMOD 2026 · 11 次引用
它引用的 Paper11
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah 等NeurIPS 2020 · 64,255 次引用
- Toolformer: Language Models Can Teach Themselves to Use ToolsTimo Schick, Jane Dwivedi-Yu, Roberto Dessì, Roberta Raileanu 等NeurIPS 2023 · 5,989 次引用
- SimCSE: Simple Contrastive Learning of Sentence EmbeddingsTianyu Gao, Xingcheng Yao, Danqi ChenEMNLP 2021 · 2,496 次引用
- QueryFormer: A Tree Transformer Model for Query Plan RepresentationYue Zhao, Gao Cong, Jiachen Shi, Chunyan MiaoVLDB 2022 · 117 次引用
- A Learned Query Rewrite System using Monte Carlo Tree SearchXuanhe Zhou, Guoliang Li, Chengliang Chai, Jianhua FengVLDB 2022 · 85 次引用
相关 Paper
- ReSequel: Robust LLM-assisted Query Rewriting and Optimization using Templatization and SamplingSaeed Fathollahzadeh, Essam Mansour, Matthias BoehmVLDB 2026
- Enhancing Conversational Search: Large Language Model-Aided Informative Query RewritingFanghua Ye, Meng Fang, Shenghui Li, Emine YilmazEMNLP Findings 2023 · 35 次引用
- Can Large Language Models Be Query Optimizer for Relational Databases?Jie Tan, Kangfei Zhao, Rui Li, Jeffrey Xu Yu 等SIGMOD 2026 · 6 次引用
- Think Then Rewrite: Reasoning Enhanced Query Rewriting for Domain Specific RetrievalAng Li, Yufei Shi, Yuxuan Si, Yiquan Wu 等AAAI 2026
- LLM4Hint: Leveraging Large Language Models for Hint Recommendation in Offline Query OptimizationSuchen Liu, Yang Lin, Yinjun Han, Jun GaoICDE 2026 · 1 次引用
