mlsanityData to 14 Oct 2026

QUITE: A Query Rewrite System Beyond Rules with LLM Agents

arXiv 2506.07675 ↗First posted 9 Jun 2025cs.DB cs.AIcited by 8

On the map: LLM agents and tool use → Web, search, and research agents

Abstract (arXiv)

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 reasoning abilities, we propose a new approach of using LLMs to rewrite SQL queries beyond rules. Due to the hallucination problems in LLMs, directly applying LLMs often leads to nonequivalent and suboptimal queries. To address this issue, we propose QUITE (query rewrite), a training-free and feedback-aware system based on LLM agents that rewrites SQL queries into semantically equivalent forms with significantly better performance, covering a broader range of query patterns and rewrite strategies compared to rule-based methods. Firstly, we design a multi-agent framework controlled by a finite state machine (FSM) to equip LLMs with the ability to use external tools and enhance the rewrite process with real-time database feedback. Secondly, we develop a rewrite middleware to enhance the ability of LLMs to generate optimized query equivalents. Finally, we employ a novel hint injection technique to improve execution plans for rewritten queries. Extensive experiments show that QUITE reduces query execution time by up to 35.8% over state-of-the-art approaches and produces 24.1% more rewrites than prior methods, covering query cases that earlier systems did not handle.

Key facts. Cited by 8 papers in the map (data through 14 Oct 2026). Placed in Web, search, and research agents, one of 16 directions in LLM agents and tool use. Builds on 27 of its 83 references that are in the map. First posted on arXiv 9 Jun 2025.

Builds on

27 of 83 references.

References · 27

  1. 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,170
  2. 2023Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflectioncited by 1,839
  3. 2023MetaGPT: Meta Programming for A Multi-Agent Collaborative Frameworkcited by 1,808
  4. 2023LongBench: A Bilingual, Multitask Benchmark for Long Context Understandingcited by 1,417
  5. 2023CAMEL: Communicative Agents for "Mind" Exploration of Large Language Model Societycited by 1,395
  6. 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,391
  7. 2023Large Language Models Can Be Easily Distracted by Irrelevant Contextcited by 841
  8. 2023LongLLMLingua: Accelerating and Enhancing LLMs in Long Context Scenarios via Prompt Compressioncited by 453
  9. 2023Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluationcited by 385
  10. 2023Multi-Agent Collaboration: Harnessing the Power of Intelligent LLM Agentscited by 333
  11. 2024A Survey on Data Selection for Language Modelscited by 236
  12. 2024BABILong: Testing the Limits of LLMs with Long Context Reasoning-in-a-Haystackcited by 215
15 more
  1. 2024CodeS: Towards Building Open-source Language Models for Text-to-SQLcited by 187
  2. 2019Neo: A Learned Query Optimizercited by 80
  3. 2020Bao: Learning to Steer Query Optimizerscited by 62
  4. 2023Reason for Future, Act for Now: A Principled Framework for Autonomous LLM Agents with Provable Sample Efficiencycited by 46
  5. 2023GPTuner: A Manual-Reading Database Tuning System via GPT-Guided Bayesian Optimizationcited by 29
  6. 2018Apache Calcite: A Foundational Framework for Optimized Query Processing Over Heterogeneous Data Sourcescited by 25
  7. 2025A Tutorial on LLM Reasoning: Relevant Methods behind ChatGPT o1cited by 25
  8. 2024LLM-R2: A Large Language Model Enhanced Rule-based Rewrite System for Boosting Query Efficiencycited by 16
  9. 2024R-Bot: An LLM-based Query Rewrite Systemcited by 16
  10. 2023Large Language Models with Retrieval-Augmented Generation for Zero-Shot Disease Phenotypingcited by 11
  11. 2025Can Large Language Models Be Query Optimizer for Relational Databases?cited by 11
  12. 2016HoTTSQL: Proving Query Rewrites with Univalent SQL Semanticscited by 10
  13. 2021Rewrite Rule Inference Using Equality Saturationcited by 10
  14. 2023LLM-SQL-Solver: Can LLMs Determine SQL Equivalence?cited by 10
  15. 2023QueryBooster: Improving SQL Performance Using Middleware Services for Human-Centered Query Rewritingcited by 5

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 4; 2026: 4.

8 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2026AV-SQL: Decomposing Complex Text-to-SQL Queries with Agentic Views
  2. 2025RAISE: Reasoning Agent for Interactive SQL Exploration
  3. 2023Query Rewriting for Retrieval-Augmented Large Language Models
  4. 2024Tool-Assisted Agent on SQL Inspection and Refinement in Real-World Scenarios
  5. 2024RaFe: Ranking Feedback Improves Query Rewriting for RAG
  6. 2026ACTS-SQL: Agentic and Critic-Oriented Tree-Structured SQL Correctness with Large Language Models
  7. 2024From Natural Language to SQL: Review of LLM-based Text-to-SQL Systems
  8. 2025IterQR: An Iterative Framework for LLM-based Query Rewrite in e-Commercial Search System