AI summary · arXiv: 2404.12872v1 · cs.DB
LLM-R2: A Large Language Model Enhanced Rule-based Rewrite System for Boosting Query Efficiency
The essentials
- Query rewrite is essential for enhancing query efficiency in database optimization.
- Traditional methods of query rewrite face challenges in finding the optimal sequence of rewrite rules.
- LLM-R2 is a novel approach that leverages a large language model to suggest potential rewrite rules while maintaining query equivalence.
- A contrastive model trained using curriculum learning enhances the inference capabilities of LLM in recommending rewrite rules.
- Experimental results show that LLM-R2 significantly improves query execution efficiency compared to baseline methods and exhibits high robustness across various datasets.
- Authors Zhaodonghui Li, Haitao Yuan, Huiming Wang, Gao Cong, and Lidong Bing have collaborated on developing an advanced rule-based rewrite system for boosting query efficiency.
Key points written by AI: they may contain errors, check them against the paper.
Ask questions about this paper to our AI assistant
How to chat with this paper? Illustrated guide
You can also chat with multiple papers at once here.
Keep this conversation — a free account saves your questions and answers, your collections of papers and your alerts.
Continue with Google Create a free accountTools for this paper
Advanced tools Premium
For researchers who follow a field closely: citation alerts, journal-club slides, version comparison and Zotero export. Discover Premium
Papers around this one
See them on a mapRanked by how close their title and abstract are to this paper’s. Select some to read them together.
Closest papers
-
GenRewrite: Query Rewriting via Large Language ModelsJie Liu, Barzan Mozafari · 2024 · Proc. ACM Manag. Data · cited 27 times · Not summarized yet
Abstract
Query rewriting is an effective technique for refining poorly written queries before they reach the query optimizer. However, manual rewriting is not scalable, as it is prone to errors and requires deep expertise. Traditional query rewriting algorithms fall short too: rule-based approaches fail to generalize to new query patterns, while synthesis-based methods struggle with complex queries. Fortunately, Large Language Models (LLMs) already possess broad knowledge and advanced reasoning capabilities, making them a promising solution for tackling these longstanding challenges. In this paper, we present GenRewrite, the first holistic system that leverages LLMs for query rewriting beyond traditi…
-
QUITE: A Query Rewrite System Beyond Rules with LLM AgentsYu-Yang Song, Han-Xu Yan, Jia-Le Lao et al. · 2025 · arXiv.org · preprint, not peer reviewed · cited 20 times · Not summarized yet
Abstract
Query rewrite transforms SQL queries into semantically equivalent forms that run more efficiently. Existing approaches mainly rely on predefined rewrite rules, but they handle a limited subset of queries and can cause performance regressions. This limitation stems from three challenges of rule-based query rewrite: (1) it is hard to discover and verify new rules, (2) fixed rewrite rules do not generalize to new query patterns, and (3) some rewrite techniques cannot be expressed as fixed rules. Motivated by the fact that human experts exhibit significantly better rewrite ability but suffer from scalability, and Large Language Models (LLMs) have demonstrated nearly human-level semantic and reas…
-
E3-Rewrite: Learning to Rewrite SQL for Executability, Equivalence,and EfficiencyDong Xu, Yue Cui, Wei-Jie Shi et al. · 2025 · arXiv.org · preprint, not peer reviewed · cited 7 times · Not summarized yet
Abstract
SQL query rewriting aims to reformulate a query into a more efficient form while preserving equivalence. Most existing methods rely on predefined rewrite rules. However, such rule-based approaches face fundamental limitations: (1) fixed rule sets generalize poorly to novel query patterns and struggle with complex queries; (2) a wide range of effective rewriting strategies cannot be fully captured by declarative rules. To overcome these issues, we propose using large language models (LLMs) to generate rewrites. LLMs can capture complex strategies, such as evaluation reordering and CTE rewriting. Despite this potential, directly applying LLMs often results in performance regressions or non-equ…
-
Enhancing Conversational Search: Large Language Model-Aided Informative Query RewritingFanghua Ye, Meng Fang, Shenghui Li et al. · 2023 · Human-Computer Interaction · cited 125 times · AI summary available
Abstract
Query rewriting plays a vital role in enhancing conversational search by transforming context-dependent user queries into standalone forms. Existing approaches primarily leverage human-rewritten queries as labels to train query rewriting models. However, human rewrites may lack sufficient information for optimal retrieval performance. To overcome this limitation, we propose utilizing large language models (LLMs) as query rewriters, enabling the generation of informative query rewrites through well-designed instructions. We define four essential properties for well-formed rewrites and incorporate all of them into the instruction. In addition, we introduce the role of rewrite editors for LLMs …
-
Query Rewriting via LLMsSriram Dharwada, Himanshu Devrani, J. Haritsa et al. · 2025 · arXiv.org · preprint, not peer reviewed · cited 10 times · Not summarized yet
Abstract
When complex SQL queries suffer slow executions despite query optimization, DBAs typically invoke automated query rewriting tools to recommend ``lean''equivalents that are conducive to faster execution. The rewritings are usually achieved via transformation rules, but these rules are limited in scope and difficult to update in a production system. Recently, LLM-based techniques have also been suggested, but they are prone to semantic and syntactic errors. We investigate here how the remarkable cognitive capabilities of LLMs can be leveraged for performant query rewriting while incorporating safeguards and optimizations to ensure correctness and efficiency. Our study shows that these goals ca…
-
R-Bot: An LLM-based Query Rewrite SystemZhaoyan Sun, Xuan-He Zhou, Guo-Liang Li et al. · 2024 · Proceedings of the VLDB Endowment · cited 55 times · Not summarized yet
Abstract
Query rewrite is essential for optimizing SQL queries to improve their execution efficiency without changing their results. Traditionally, this task has been tackled through heuristic and learning-based methods, each with its limitations in terms of inferior quality and low robustness. Recent advancements in LLMs offer a new paradigm by leveraging their superior natural language and code comprehension abilities. Despite their potential, directly applying LLMs like GPT-4 has faced challenges due to problems such as hallucinations, where the model might generate inaccurate or irrelevant results. To address this, we propose R-Bot , an LLM-based query rewrite system with a systematic approach. W…
-
LLM-MVs: An LLM-Enhanced Materialized Views-Based Query Rewriting SystemChong Sun, Hao Hu, Huili Zhang et al. · 2025 · IEEE International Conference on e-Business Engineering · Not summarized yet
Abstract
Query rewriting, which aims to enhance query efficiency by modifying the structure of SQL queries without altering their results, stands as one of the pivotal research directions in the database domain. Traditional query rewriting approaches perform language-equivalent transformations based on manually predefined rewriting rules, thereby failing to fully harness the potential of Materialized Views (MVs) for query optimization. Furthermore, with the emergence of Large Language Models (LLMs), natural language interaction with LLMs can better unlock the potential of MVs in query rewriting. Nevertheless, the direct application of LLMs for query rewriting exhibits several limitations, including o…
-
ReSequel: Robust LLM-assisted Query Rewriting and Optimization using Templatization and SamplingSaeed Fathollahzadeh, Essam Mansour, Matthias Boehm · 2026 · Proceedings of the VLDB Endowment · Not summarized yet
Abstract
Heuristic query rewriting has long complemented cost-based optimization to improve performance. Such rewrites transform SQL queries into semantically equivalent forms that are easier or faster to execute. Examples are standardizing expressions, eliminating redundancy, propagating constants, pushing down selections and projections, unnesting queries, and utilizing constraints. Modern DBMSs implement hundreds to thousands of such rules, but maintaining them is notoriously difficult. The interactions among rules are complex, and their static nature and application order prevent adaptation to specific query and database characteristics. Recent approaches that use large language models (LLMs) for…
Prior work it builds on
-
A Learned Query Rewrite System using Monte Carlo Tree SearchXuan-He Zhou, Guo-Liang Li, Cheng-Liang Chai et al. · 2021 · Proceedings of the VLDB Endowment · cited 97 times · Not summarized yet
Abstract
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. Existi…
-
WeTune: Automatic Discovery and Verification of Query Rewrite RulesZhao-Guo Wang, Zhou Zhou, Yicun Yang et al. · 2022 · SIGMOD Conference · cited 67 times · Not summarized yet
Abstract
Query rewriting transforms a relational database query into an equivalent but more efficient one, which is crucial for the performance of database-backed applications. Such rewriting relies on pre-specified rewrite rules. In existing systems, these rewrite rules are discovered through manual insights and accumulate slowly over the years. In this paper, we present WeTune, a rule generator that automatically discovers new rewrite rules. Inspired by compiler superoptimization, WeTune enumerates all valid logical query plans up to a certain size and tries to discover equivalent plans that could potentially lead to more efficient rewrites. The core challenge is to determine which set of condition…
-
SQL-PaLM: Improved Large Language Model Adaptation for Text-to-SQLRuoxi Sun, Sercan Ö. Arik, Alex Muzio et al. · 2024 · Trans. Mach. Learn. Res. · cited 111 times · Not summarized yet
-
Can LLM Already Serve as A Database Interface? A BIg Bench for Large-Scale Database Grounded Text-to-SQLsJinyang Li, Binyuan Hui, Ge Qu et al. · 2023 · Neural Information Processing Systems · cited 1,358 times · AI summary available
Abstract
Text-to-SQL parsing, which aims at converting natural language instructions into executable SQLs, has gained increasing attention in recent years. In particular, Codex and ChatGPT have shown impressive results in this task. However, most of the prevalent benchmarks, i.e., Spider, and WikiSQL, focus on database schema with few rows of database contents leaving the gap between academic study and real-world applications. To mitigate this gap, we present Bird, a big benchmark for large-scale database grounded in text-to-SQL tasks, containing 12,751 pairs of text-to-SQL data and 95 databases with a total size of 33.4 GB, spanning 37 professional domains. Our emphasis on database values highlights…
-
ReAct: Synergizing Reasoning and Acting in Language ModelsShunyu Yao, Jeffrey Zhao, Dian Yu et al. · 2022 · International Conference on Learning Representations · cited 13,359 times · Not summarized yet
Abstract
While large language models (LLMs) have demonstrated impressive capabilities across tasks in language understanding and interactive decision making, their abilities for reasoning (e.g. chain-of-thought prompting) and acting (e.g. action plan generation) have primarily been studied as separate topics. In this paper, we explore the use of LLMs to generate both reasoning traces and task-specific actions in an interleaved manner, allowing for greater synergy between the two: reasoning traces help the model induce, track, and update action plans as well as handle exceptions, while actions allow it to interface with external sources, such as knowledge bases or environments, to gather additional in…
Papers that cite it
-
Large Language Models in Database Management System Optimization: A SurveySikha S. Bagui, M. Malagutti, Riccardo Morelli et al. · 2026 · ACM Transactions on Intelligent Systems and Technology · cited 2 times · Not summarized yet
Abstract
Large language models have demonstrated remarkable capabilities in reasoning, code generation, and knowledge integration, making them increasingly relevant across a range of data-intensive applications. Their potential to interpret natural language, synthesize domain knowledge, and adapt to complex tasks has recently motivated research on their use within database management systems to enhance performance and automation. This survey reviews how these models have been employed to support core optimization tasks in modern databases, including query processing, system tuning, indexing, and performance diagnostics. We examine the methodological foundations, such as fine-tuning and RAG, and analy…
-
SPA: A SQL-Plan-Aware Reinforcement Learning Framework for Query Rewriting with LLMsXin-Yi Huang, Zheng-Jie Miao · 2026 · arXiv.org · preprint, not peer reviewed · cited 1 time · Not summarized yet
Abstract
SQL query rewriting is a well-established technique for improving database performance without schema or index changes, yet finding effective rewrites for modern analytical workloads remains difficult: rule-based methods are limited to predefined transformations, while LLM-based approaches often produce rewrites that are semantically valid but compile to equivalent physical plans or degrade runtime performance. We present SPA, a SQL-Plan-Aware reinforcement learning framework that trains LLMs to rewrite queries using physical execution feedback. SPA formulates rewriting as a policy optimization problem and extends GRPO with rewards spanning semantic equivalence, textual rewrite distance, phy…
-
Cracking SQL Barriers: An LLM-based Dialect Translation SystemWei Zhou, Yu-Yang Gao, Xuan-He Zhou et al. · 2025 · Proc. ACM Manag. Data · cited 26 times · Not summarized yet
Abstract
Automatic dialect translation reduces the complexity of database migration, which is crucial for applications interacting with multiple database systems. However, rule-based translation tools (e.g., SQLGlot, jOOQ, SQLines) are labor-intensive to develop and often (1) fail to translate certain operations, (2) produce incorrect translations due to rule deficiencies, and (3) generate translations compatible with some database versions but not the others. In this paper, we investigate the problem of automating dialect translation with large language models (LLMs). There are three main challenges. First, queries often involve lengthy content (e.g., excessive column values) and multiple syntax ele…
-
Training-Free Query Optimization via LLM-Based Plan SimilarityNikita K. Vasilenko, Alexander Demin, Vladimir Boorlakov · 2025 · The Bulletin of Irkutsk State University. Series Mathematics · cited 2 times · Not summarized yet
Abstract
Large language model (LLM) embeddings offer a promising new avenue for database query optimization. In this paper, we explore how pre-trained execution plan embeddings can guide SQL query execution without the need for additional model training. We introduce LLM-based Plan Mapping (LLM-PM), a framework that embeds the default execution plan of a query, finds its k nearest neighbors among previously executed plans, and recommends database hintsets based on neighborhood voting. A lightweight consistency check validates the selected hint, while a fallback mechanism searches the full hint space when needed. Evaluated on the JOB-CEB benchmark using openGauss, LLM-PM achieves an average 21% reduct…
-
SQLBarber: A System Leveraging Large Language Models to Generate Customized and Realistic SQL WorkloadsJia-Le Lao, Immanuel Trummer · 2025 · Proc. ACM Manag. Data · cited 12 times · Not summarized yet
Abstract
Database research and development often require a large number of SQL queries for benchmarking purposes. However, acquiring real-world SQL queries is challenging due to privacy concerns, and existing generation methods offer limited options for customization and for satisfying realistic constraints. To address this issue, we present SQLBarber, a system based on Large Language Models (LLMs) to generate customized and realistic SQL workloads. SQLBarber (1) eliminates the need for users to manually craft SQL templates in advance, while providing the flexibility to accept natural language specifications to constrain SQL templates, (2) scales efficiently to generate large volumes of queries match…
Go further
How are these papers found?
We compare the title and abstract of this paper with those of every paper summarized on this site, and with the papers Semantic Scholar recommends, those it cites and those citing it (for a much-cited paper, its most recent citations and, from OpenAlex, the most cited ones). Among the prior work and the follow-ups, the papers that use each other in depth, a method it uses and the much-cited follow-ups come a little higher. The levels (very close, close, related) come from the similarity of the texts, not from a judgment of quality; * marks a paper without an abstract, compared by its title. The sentence under a paper is written by an AI from the two abstracts: check it in the papers. A paper marked not relevant by three readers leaves the list.
Updated on 2 November 2026.
The previous summary was created more than a year ago and can be re-run (if necessary) by clicking on the Run button below.
Disclaimer: The AI-based summarization tool and virtual assistant provided on this website may not always provide accurate and complete summaries or responses. We encourage you to carefully review and evaluate the generated content to ensure its quality and relevance to your needs.