GenRewrite: Query Rewriting via Large Language Models
Not on the map. Why?
Abstract (arXiv)
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 traditional rules. We introduce the notion of Natural Language Rewrite Rules (NLR2s), which serve as hints for the LLM while also a means of knowledge transfer from rewriting one query to another, allowing GenRewrite to become smarter and more effective over time. We present a novel counterexample-guided technique that iteratively corrects the syntactic and semantic errors in the rewritten query, significantly reducing the LLM costs and the manual effort required for verification. Across the standard TPC-DS and JOB benchmarks and their SQLStorm-generated variants, GenRewrite consistently optimizes more queries at every speedup threshold than all baselines. At the >=2x threshold on TPC-DS, GenRewrite improves 25 queries-1.35x more than LLM-driven baselines and 2.6x more than LLM-enhanced rule-based baselines-and the gap widens further on TPC-DS (SQLStorm); on JOB and its SQLStorm variant, where queries are simpler, absolute gains are smaller but GenRewrite still leads by a notable margin.
Key facts. Cited by 11 papers in the map (data through 7 Oct 2026). First posted on arXiv 14 Mar 2024.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2024: 2; 2025: 7; 2026: 2.
11 papers.
- 2024When Search Engine Services meet Large Language Models: Visions and Challengescited by 59
- 2025A Survey of Data Agents: Emerging Paradigm or Overstated Hype?cited by 30
- 2025MIRIAD: Augmenting LLMs with millions of medical query-response pairscited by 8
- 2024Towards Action Hijacking of Large Language Model-based Agentcited by 4
- 2025A New Query Expansion Approach via Agent-Mediated Dialogic Inquirycited by 2
- 2025Cognitive-Aligned Document Selection for Retrieval-augmented Generationcited by 1
- 2025QueryBandits for Hallucination Mitigation: Exploiting Semantic Features for No-Regret Rewritingcited by 1
- 2025REVISION:Reflective Intent Mining and Online Reasoning Auxiliary for E-commerce Visual Search System Optimizationcited by 1
- 2026RuleFlow : Generating Reusable Program Optimizations with LLMscited by 1
- 2025LLMs and Agentic AI in Insurance Decision-Making: Opportunities and Challenges For Africacited by 0
- 2026Search-GRT: Guided Retrieval Training of Search Agents to Optimize for Complex Question Answeringcited by 0
- 2026Search-GRT: Guided Retrieval Training of Search Agents to Optimize for Complex Question Answering2 Aug 2026
- 2026RuleFlow : Generating Reusable Program Optimizations with LLMs6 Feb 2026
- 2025A Survey of Data Agents: Emerging Paradigm or Overstated Hype?27 Oct 2025
- 2025REVISION:Reflective Intent Mining and Online Reasoning Auxiliary for E-commerce Visual Search System Optimization26 Oct 2025
- 2025QueryBandits for Hallucination Mitigation: Exploiting Semantic Features for No-Regret Rewriting22 Aug 2025
- 2025LLMs and Agentic AI in Insurance Decision-Making: Opportunities and Challenges For Africa20 Aug 2025
- 2025MIRIAD: Augmenting LLMs with millions of medical query-response pairs6 Jun 2025
- 2025Cognitive-Aligned Document Selection for Retrieval-augmented Generation17 Feb 2025
- 2025A New Query Expansion Approach via Agent-Mediated Dialogic Inquiry12 Feb 2025
- 2024Towards Action Hijacking of Large Language Model-based Agent14 Dec 2024
- 2024When Search Engine Services meet Large Language Models: Visions and Challenges28 Jun 2024