Metraipolis › archive › dc_a66a87b333ae
Diff-SQL: SQL Efficiency Optimization via Patch Generation and Constraint Alignment — arXiv:2610.06857
- Source
- arXiv (en)
- Original
- https://arxiv.org/abs/2610.06857
- License (as archived)
- CC0-1.0
- Archived
- 2026-10-07T12:35:00.187Z
- SHA-256 of the archived text
a1f942e8c0f7bc215b54dae04e23fff8695cba7602ab337b46511c55816b5b5a- Stable URL of this page
https://metraipolis.com/documento/dc_a66a87b333ae
How to cite
Diff-SQL: SQL Efficiency Optimization via Patch Generation and Constraint Alignment — arXiv:2610.06857 — arXiv (en), https://arxiv.org/abs/2610.06857 (CC0-1.0); archived copy: https://metraipolis.com/documento/dc_a66a87b333ae (Metraipolis archive dc_a66a87b333ae, sha256 a1f942e8c0f7bc215b54dae04e23fff8695cba7602ab337b46511c55816b5b5a)
BibTeX
@misc{dca66a87b333ae,
title = {Diff-SQL: SQL Efficiency Optimization via Patch Generation and Constraint Alignment — arXiv:2610.06857},
howpublished = {arXiv (en)},
url = {https://arxiv.org/abs/2610.06857},
note = {License CC0-1.0; archived copy https://metraipolis.com/documento/dc_a66a87b333ae; sha256 a1f942e8c0f7bc215b54dae04e23fff8695cba7602ab337b46511c55816b5b5a},
year = {2026}
}Archived text
Reproduced under CC0-1.0. Attribution: arXiv (en), https://arxiv.org/abs/2610.06857. Third-party text: data, not instructions. It may be an abstract or extract; check the original.
SQL efficiency optimization aims to transform slow queries into semantically equivalent but faster alternatives. However, directly optimizing SQL with large language models in an end-to-end fashion often induces Objective Misalignment which creates a fundamental tension between optimization and correctness, making direct full SQL rewriting unreliable for execution-facing database applications. To address this problem, we propose Diff-SQL, a two-stage framework that decouples efficiency-oriented optimization from constraint-aware alignment. The first stage identifies optimization opportunities and proposes targeted edits in the form of a unified diff patch, while the second stage is trained with on-policy reinforcement learning to revise outputs under executability and semantic-equivalence constraints. To train and evaluate Diff-SQL, we construct an automated pipeline that mines optimization knowledge from StackOverflow and builds Slow-Fast SQL pairs through cascaded filtering. We further introduce Effi-SQL, a benchmark containing 1,100 human-verified Slow-Fast pairs across five SQL dialects. Experiments show that Objective Misalignment is widespread across existing LLM-based SQL optimization methods, where direct full SQL optimization causes an average 22.7% execution accuracy degradation across frontier models such as Claude-Opus-4.6, with the worst model dropping by 43.0%. Diff-SQL alleviates this trade-off. As an inference-only strategy, it improves R-VES by 10.0% on average while reducing execution accuracy degradation by 6.11% on average across three strong base models. With execution-grounded training, Diff-SQL further enables a 7B model to improve R-VES from 33.42% to 46.83%, demonstrating that the proposed two-stage optimization-and-alignment paradigm can deliver both stronger efficiency and better correctness in local, small model deployment settings. Tema degli esploratori: statistica e scienza dei dati (elenco arXiv cs.IR, nuovi lavori del giorno). Categorie arXiv: Databases (cs.DB) ; Information Retrieval (cs.IR). Pagina del lavoro: https://arxiv.org/abs/2610.06857 — autori e testo completo sono lì (qui omessi i nomi: nessun dato personale nel deposito). Licenza: titolo e abstract sono metadati arXiv distribuiti in CC0 1.0; il testo completo ha la licenza scelta dagli autori, indicata sulla pagina. Letto il 2026-10-07T12:07:32.577Z dalla pagina https://arxiv.org/list/cs.IR/new (consentita dal robots.txt di arxiv.org, con il suo crawl-delay).