# Verified LLM-Based Query Rewriting for Microsoft SQL Server

> Source: <https://al.radbox.org/doi/10.14778/3827998.3828074>
> Published: 2026-12-05 01:43:23+00:00

**Recommendation:** Verify every LLM-proposed query rewrite for semantic equivalence with the database optimizer before applying it, and cap the search with an anytime algorithm so slow verification steps are short-circuited within the time budget.
More in the playbook "Verifying model output": <https://wpnews.pro/playbooks/output-verification>

Verified LLM-Based Query Rewriting for Microsoft SQL Server
Authors:
 
Kukjin Lee
, 
Anshuman Dutt
, 
Vivek Narasayya
, 
Surajit Chaudhuri
Published:
 
Proceedings of the VLDB Endowment, volume 19, issue 12, pp. 4594-4597. August 1, 2026.
Abstract:
 
Query rewriting is one of the techniques used by database developers and administrators to tune the performance of poorly performing SQL queries. We have developed an LLM-based query tuning tool for Microsoft SQL Server that takes as input a query, tuning constraints such as minimum required improvement and time budget, and automatically recommends semantically equivalent query rewrites that improve the execution time of the query. The software tool is incorporated as an extension to SQL Server Management Studio (SSMS). Our demonstration highlights two important capabilities. First, while LLMs have the ability to generate promising candidate rewrites for the given query, they cannot guarantee semantic equivalence of a query rewrite. We use a technique we developed for verifying semantic equivalence of two queries, which leverages the built-in capabilities of Microsoft SQL Server's query optimizer. Second, we judiciously use the given time budget by adopting an anytime tuning algorithm and employing optimizations that help short-circuit the expensive steps of verification and execution for each candidate rewrite. To the best of our knowledge this is the first tool of its kind that enables DBAs and application developers to safely operationalize LLM-based query rewriting.
BibTeX:
 

```
@article{lee2026,
  title = {{Verified LLM-Based Query Rewriting for Microsoft SQL Server}},
  author = {Kukjin Lee and Anshuman Dutt and Vivek Narasayya and Surajit Chaudhuri},
  journal = {Proceedings of the VLDB Endowment},
  volume = {19},
  issue = {12},
  year = 2026,
  month = 8,
  day = 1,
  doi = {10.14778/3827998.3828074},
}
```
