arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2604.06804cs.DB
收藏

LASER: 一种数据驱动的低成本高效SQL重写方法基于SQL-GRPO

LASER: A Data-Centric Method for Low-Cost and Efficient SQL Rewriting based on SQL-GRPO

Zhejiang University(浙江大学);ByteDance Inc(字节跳动)

Jiahui Li, Tongwang Wu, Yuren Mao, Rong Kang, Tieying Zhang, Yunjun Gao

AI总结:

本文提出LASER,一种数据驱动的SQL重写方法,通过构建SQL-MCTS大规模语料库和SQL-GRPO专用对齐策略,提升小模型在SQL优化中的执行效率和零样本迁移能力。

摘要:

查询重写,即将查询转换为语义等价但更高效的变体,是数据库优化的关键。现有解决方案主要依赖规则启发式或大语言模型(LLMs)。然而,传统规则方法缺乏适应性,而LLM方法则带来高昂的推理成本和隐私风险。相比之下,小语言模型(SLMs)提供了一个有吸引力的中间地带,可能在灵活性和效率方面取得平衡。然而,开发此类紧凑模型受到高质量、领域特定训练数据稀缺的严重限制。为此,我们引入LASER,一种数据驱动的框架,旨在增强小模型在SQL优化中的鲁棒性。首先,为了解决现有基准的稀缺性和通用合成查询的有限优化空间,我们构建了SQL-MCTS,一个大规模复杂慢查询语料库。我们采用基于MCTS的混合扩展策略,结合规则引导的反模式和LLM突变,将结构表达性强的种子演化为执行验证的慢变体。其次,为了使模型能够自主发现延迟感知的重写模式,我们提出SQL-GRPO,一种从组相对策略优化衍生的专用对齐策略。通过整合Anchored Group Advantage来细化优势估计和Complexity-Adaptive Dynamic Rollout来高效分配探索预算,该方法有效使紧凑模型掌握基于执行的优化逻辑。在Qwen3模型上实现后,LASER在执行效率上显著优于规则系统和LLMs,同时表现出稳健的零样本迁移能力,且具有最小的开销。

英文摘要:

Query rewriting, the process of transforming queries into semantically equivalent yet more efficient variants, is crucial for database optimization. Existing solutions predominantly rely on either rule-based heuristics or Large Language Models (LLMs). However, traditional rule-based methods lack adaptability, while LLM-based approaches incur prohibitive inference costs and privacy risks. In contrast, Small Language Models (SLMs) present a compelling middle ground, potentially offering both flexibility and efficiency. However, the development of such compact models is severely bottlenecked by the scarcity of high-quality, domain-specific training data. To bridge this gap, we introduce LASER, a data-centric framework designed to empower small models for robust SQL optimization. First, to address the scarcity of existing benchmarks and the limited optimization headroom of generic synthetic queries, we construct SQL-MCTS, a large-scale corpus of complex slow queries. We employ an MCTS-based hybrid expansion strategy that combines rule-guided anti-patterns with LLM mutations to evolve structurally expressive seeds into execution-verified slow variants. Second, to enable the model to autonomously discover latency-aware rewriting patterns, we propose SQL-GRPO, a specialized alignment strategy adapted from Group Relative Policy Optimization. By integrating Anchored Group Advantage to refine advantage estimation and Complexity-Adaptive Dynamic Rollout to efficiently allocate exploration budgets, this approach effectively empowers compact models to master execution-based optimization logic. Implemented on Qwen3 models, LASER significantly outperforms rule-based systems and LLMs in execution efficiency, while exhibiting robust zero-shot transferability with minimal overhead.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑