Skip to content

SQL-RewriteBench: A Correctness-Gated, Full-Denominator Benchmark for Statement-Level SQL Rewriting [Experiment,Analysis & Benchmark]

Jul 2026 · arXiv.org · Vol abs/2607.09251 · 0 citations · 31 references
Computer Science

TL;DR

SQL-RewriteBench is presented, a benchmark for statement-level SQL rewriting that applies correctness gating and full-denominator accounting and shows that deployable SQL rewrite requires broader input handling, result validation, and benefit-aware rewrite decisions.

Abstract

Statement-level SQL rewriting can improve query performance and maintainability without changing the DBMS kernel, but existing benchmarks do not evaluate rewrite methods as deployable systems. They typically focus on DBMS performance, rule regression, query equivalence, or dialect translation, while missing the full path from accepting an input query to producing an executable, result-consistent, and operationally useful rewrite. We present SQL-RewriteBench, a benchmark for statement-level SQL rewriting that applies correctness gating and full-denominator accounting. Its metric suite explicitly separates Source Acceptance, Generation Rate, Execution Coverage, Result Consistency, UnsafeRewrite Rate, and speedup distribution. It also defines SCS, a deterministic index of static SQL structure, and CGOQ, a correctness-gated optimization-quality score that gives optimization credit only after the case-specific Checker Contract is satisfied. CGOQ combines runtime improvement with structural simplification through a continuous scoring function, making it suitable for deployment-oriented rewrite assessment. As an artifact, SQL-RewriteBench provides 180 executable Benchmark Instances organized into EQUIV, PERF, ROBUST, and DIALECT pools, each packaged with SQL, schema metadata, provenance, evidence, and rewrite-opportunity documentation. Across seven representative academic and LLM-based methods, every full-benchmark CGOQ is negative. Existing methods often fail before rewriting, fail result checks, or return correct rewrites that are slower or no better than the input. These results show that deployable SQL rewrite requires broader input handling, result validation, and benefit-aware rewrite decisions.

View source

Similar papers

Open access Oct 2026

Cracking Query Bottlenecks: Towards Efficiency-Oriented Text-to-SQL Generation

Text-to-SQL models translate natural language questions into SQL, enabling non-technical users to access databases. However, most existing research focuses on correctness, neglecting query efficiency. In this paper, we address the challenge of evaluating the execution efficiency of generated SQL in Text-to-SQL by intro...

Li Lin, Yun-Feng Shen, Ling-Feng Bao et al. · 0 citations
Book Open access Apr 2026

DBcover: A White-box SQL Test Generation Framework for Coverage Improvement

DBcover is proposed, an LLM-driven database test generation framework that performs white-box, code-aware SQL test generation through contextual reasoning, and substantially outperforms existing fuzzers.

Yan-Kai Rong, Shuang Liu, Jin-Hao Dong et al. · 0 citations
Open access Sep 2026

MimicDB: Runtime Defense against Wrong-Result Bugs in Database Query Optimizers via Query-Rewriting Diversity

These findings characterize the potential of single-engine diversity to detect wrong-result failures and select correct results, together with the execution costs and reference-validity constraints that shape its practical use.

Ze-Lin Wang, Ping Chen, Jin Wei et al. · 0 citations
Preprint Aug 2026

TraceSQL: Traceable Answerability Estimation for Reference-Free Text-to-SQL Verification

Results show that SQL verification can be performed with a lightweight learned model while retaining feature-level evidence for inspecting and diagnosing its predictions, and feature attribution shows that the model relies on both semantic grounding and deterministic SQL-structure signals.

N. Shukla, Debasmita Panda, Srutanik Bhaduri et al. · 0 citations
Book Open access Aug 2026

AutoSQL: Extracting SQL Templates from Imperative ORM Code in Large-Scale Repositories

This work presents AutoSQL, a system that reconstructs SQL templates from Go ORM code that constructs a Code Index, a directed graph that captures structural dependencies between functions, types, and global variables as navigable edges and synthesizes SQL templates.

Jun-Song Pu, Yi-Chen Li, Zhuang-Bin Chen et al. · 0 citations
Jul 2026

Developing and Benchmarking Verification Algorithms to Improve Text-to-SQL Generation

This work formalizes Text-to-SQL verification as a standalone task: assessing whether a candidate SQL query semantically satisfies a natural language request, without access to ground-truth labels, and proposes and compares two modular verification strategies.

Tarfah Alrashed, Madhup Sukoon, David R Karger et al. · 0 citations

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.