[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-detail-82269-en":3,"doc-seo-82269-105":29,"detail-sidebar-cat-0-en-105":90},{"code":4,"msg":5,"data":6},0,"success",{"doc_id":7,"user_id":8,"nickname":9,"user_avatar":10,"doc_module":4,"category_id":11,"category_name":12,"doc_title":13,"doc_description":14,"doc_content":15,"file_id":16,"file_url":17,"file_type":18,"file_size":19,"view_count":4,"is_deleted":4,"is_public":20,"is_downloadable":20,"audit_status":20,"page_count":21,"language":22,"language_code":23,"site_id":24,"html_lang":23,"table_of_contents":25,"faqs":26,"seo_title":13,"seo_description":14,"update_tm":27,"read_time":28},82269,962075114101,"Seraphina","https://ap-avatar.wpscdn.com/avatar/e000253a75eb197efd?x-image-process=image/resize,m_fixed,w_180,h_180&k=1780044092746381165",8,"Research & Report","SQL RewriteBench A Correctness-Gated Full-Denominator Benchmark for Statement-Level SQL Rewriting","Statement-level SQL rewriting improves query performance and maintainability without modifying the DBMS kernel, yet prior benchmarks evaluate only partial aspects such as DBMS performance, rule regression, equivalence, or dialect translation. SQL-RewriteBench introduces correctness gating and full-denominator accounting for the full deployable path from input acceptance to executable, result-consistent rewrites. It separates Source Acceptance, generation, execution coverage, result consistency, unsafe rates, and speedup distributions, using SCS and CGOQ to credit only after checker validation.","arXiv :2607 .09251v1 [ cs .DB] 10 Jul 2026  \nSQL-RewriteBench: A Correctness-Gated, Full-Denominator Benchmark for Statement-Level SQL Rewriting [Experiment,  \nAnalysis & Benchmark]  \nJiang Long 1,2 Haochen Zhang2  \nTianci Gao2 Shiyuan Hao2 Shuncheng Liu2 Jiang Zhang2  \n1 Zhejiang University, Hangzhou, China  \n2 Huawei Company, China  \n[longjiang1@zju.edu.cn](longjiang1@zju.edu.cn) [gao.tianci@huawei-partners.com](gao.tianci@huawei-partners.com)  \n[haoshiyuan@huawei.com](haoshiyuan@huawei.com) [zhanghaochen6@huawei-partners.com](zhanghaochen6@huawei-partners.com)[ ](zhanghaochen6@huawei-partners.com)[liushuncheng1@huawei.com](liushuncheng1@huawei.com) [zhangjiang13@huawei.com](zhangjiang13@huawei.com)  \nAbstract  \nStatement-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.  \nWe 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.  \nAs 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.  \n1 Introduction  \nSQL rewrite is a long-standing database optimization technique: optimizers and external tools transform a SQL statement to expose better plans, simplify expressions, decorrelate subqueries, push predicates, or remove redundant structure [10, 11 , 19 , 20] . Recent systems revisit statement-level rewrite outside the DBMS kernel, using rule search, learned rule selection, retrieval, or language models to generate a replacement SQL statement [16, 21 , 23 , 32] . This deployment model has a visible SQL-in/SQL-out contract: a method must accept the input, decide whether to rewrite, emitone Rewritten Query, and submit it to the evaluation DBMS.  \nExisting benchmarks and tools do not fully capture this rewrite-specific SQL-in/SQL-out contract. DBMS workloads such as TPC-H, TPC-DS, DSB, and JOB measure execution or optimizer behavior [7, 14 , 24 , 25]; dialect datasets study translation [31]; equivalence systems decide supplied query pairs over supported fragments [3, 8 , 12 , 26 , 29] . To our knowledge, no existing resource keeps Source Acceptance Failure, No-Rewrite Decision, invalid generation, DBMS execution failure, result inconsistency, Unsafe Rewrite, speedup distribution, and structural simplification in one explicit denominator. As a result, an average speedup over successful cases can hide many operational failures.  \nSQL-RewriteBench addresses this gap. Its first contribution is methodological. We define a denominator-explicit metric suite for deployable SQL rewrite and introduce two script-computabl","cbCailp2bYVTChjs","https://ap.wps.com/l/cbCailp2bYVTChjs","pdf",551465,1,23,"English","en",105,"# Abstract\n# Introduction\n# Related Work","[{\"question\":\"What gap does SQL-RewriteBench target in existing SQL rewriting benchmarks?\",\"answer\":\"Existing benchmarks do not capture the deployable SQL-in/SQL-out contract end to end, such as acceptance decisions, executable generation, DBMS execution, result consistency, unsafe rewrite handling, and a unified denominator for operational failures.\"},{\"question\":\"Which metrics and scoring mechanisms does SQL-RewriteBench introduce?\",\"answer\":\"It provides a metric suite separating Source Acceptance, Generation Rate, Execution Coverage, Result Consistency, UnsafeRewrite Rate, and speedup distribution. It also defines SCS for deterministic static structure and CGOQ, which grants optimization credit only after a case-specific Checker Contract is satisfied.\"},{\"question\":\"How is the benchmark artifact organized and what do instances contain?\",\"answer\":\"The release includes 180 executable Benchmark Instances across EQUIV, PERF, ROBUST, and DIALECT pools. Each instance is packaged with SQL, schema metadata, provenance and evidence, a Checker Contract, and rewrite-opportunity documentation for evaluation harness execution and ledger reporting.\"}]",1784179291,58,{"code":4,"msg":30,"data":31},"ok",{"site_id":24,"language":23,"slug":32,"title":13,"keywords":33,"description":14,"schema_data":34,"social_meta":85,"head_meta":87,"extra_data":89,"updated_unix":27},"sql-rewritebench-a-correctness-gated-full-denominator-benchmark-for-statement-level-sql-rewriting","",{"@graph":35,"@context":84},[36,53,67],{"@type":37,"itemListElement":38},"BreadcrumbList",[39,43,47,50],{"item":40,"name":41,"@type":42,"position":20},"https://docshare.wps.com","Home","ListItem",{"item":44,"name":45,"@type":42,"position":46},"https://docshare.wps.com/document/","Document",2,{"item":48,"name":12,"@type":42,"position":49},"https://docshare.wps.com/document/research-report/",3,{"item":51,"name":13,"@type":42,"position":52},"https://docshare.wps.com/document/sql-rewritebench-a-correctness-gated-full-denominator-benchmark-for-statement-level-sql-rewriting/82269/",4,{"url":51,"name":13,"@type":54,"author":55,"headline":13,"publisher":57,"fileFormat":60,"inLanguage":23,"description":14,"dateModified":61,"datePublished":61,"encodingFormat":60,"isAccessibleForFree":62,"interactionStatistic":63},"DigitalDocument",{"name":9,"@type":56},"Person",{"url":40,"name":58,"@type":59},"DocShare","Organization","application/pdf","2026-07-16",true,{"@type":64,"interactionType":65,"userInteractionCount":4},"InteractionCounter",{"@type":66},"ViewAction",{"@type":68,"mainEntity":69},"FAQPage",[70,76,80],{"name":71,"@type":72,"acceptedAnswer":73},"What gap does SQL-RewriteBench target in existing SQL rewriting benchmarks?","Question",{"text":74,"@type":75},"Existing benchmarks do not capture the deployable SQL-in/SQL-out contract end to end, such as acceptance decisions, executable generation, DBMS execution, result consistency, unsafe rewrite handling, and a unified denominator for operational failures.","Answer",{"name":77,"@type":72,"acceptedAnswer":78},"Which metrics and scoring mechanisms does SQL-RewriteBench introduce?",{"text":79,"@type":75},"It provides a metric suite separating Source Acceptance, Generation Rate, Execution Coverage, Result Consistency, UnsafeRewrite Rate, and speedup distribution. It also defines SCS for deterministic static structure and CGOQ, which grants optimization credit only after a case-specific Checker Contract is satisfied.",{"name":81,"@type":72,"acceptedAnswer":82},"How is the benchmark artifact organized and what do instances contain?",{"text":83,"@type":75},"The release includes 180 executable Benchmark Instances across EQUIV, PERF, ROBUST, and DIALECT pools. Each instance is packaged with SQL, schema metadata, provenance and evidence, a Checker Contract, and rewrite-opportunity documentation for evaluation harness execution and ledger reporting.","https://schema.org",{"og:url":51,"og:type":86,"og:title":13,"og:site_name":58,"og:description":14},"article",{"robots":88,"canonical":51},"index,follow",{"doc_id":7,"site_id":24},{"code":4,"msg":5,"data":91},[92,96,100,104,109,114,119,122,127,130,134],{"id":20,"doc_module":4,"doc_module_name":45,"category_name":93,"show_sort_weight":94,"slug":95},"Story & Novel",90,"story-novel",{"id":46,"doc_module":4,"doc_module_name":45,"category_name":97,"show_sort_weight":98,"slug":99},"Literature",80,"literature",{"id":52,"doc_module":4,"doc_module_name":45,"category_name":101,"show_sort_weight":102,"slug":103},"Exam",70,"exam",{"id":105,"doc_module":4,"doc_module_name":45,"category_name":106,"show_sort_weight":107,"slug":108},5,"Comic",60,"comic",{"id":110,"doc_module":4,"doc_module_name":45,"category_name":111,"show_sort_weight":112,"slug":113},6,"Technology",50,"technology",{"id":115,"doc_module":4,"doc_module_name":45,"category_name":116,"show_sort_weight":117,"slug":118},7,"Healthcare",40,"healthcare",{"id":11,"doc_module":4,"doc_module_name":45,"category_name":12,"show_sort_weight":120,"slug":121},30,"research-report",{"id":123,"doc_module":4,"doc_module_name":45,"category_name":124,"show_sort_weight":125,"slug":126},9,"Religion & Spirituality",20,"religion-spirituality",{"id":125,"doc_module":4,"doc_module_name":45,"category_name":128,"show_sort_weight":125,"slug":129},"World Cup","world-cup",{"id":131,"doc_module":4,"doc_module_name":45,"category_name":132,"show_sort_weight":131,"slug":133},10,"Lifestyle","lifestyle",{"id":135,"doc_module":4,"doc_module_name":45,"category_name":136,"show_sort_weight":105,"slug":137},19,"General","general"]