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.


翻译:查询重写,即将查询转换为语义等价但执行效率更高的变体,是数据库优化的关键环节。现有解决方案主要依赖基于规则的启发式方法或大型语言模型(LLM)。然而,传统规则方法缺乏适应性,而基于LLM的方法则面临高昂推理成本与隐私风险。相比之下,小型语言模型(SLM)提供了一个兼具灵活性与效率的折中方案。然而,此类紧凑型模型的开发受限于高质量领域特定训练数据的稀缺性。为弥补这一不足,我们提出LASER——一个旨在赋能小模型实现稳健SQL优化的数据驱动框架。首先,针对现有基准数据稀缺及通用合成查询优化空间有限的问题,我们构建了SQL-MCTS——一个包含复杂慢查询的大规模语料库。我们采用基于蒙特卡洛树搜索(MCTS)的混合扩展策略,将规则引导的反模式与LLM变异相结合,将结构表达力丰富的种子查询逐步演化为经执行验证的慢查询变体。其次,为使模型能够自主发现时延感知的重写模式,我们提出SQL-GRPO——一种基于分组相对策略优化改进的特化对齐策略。该策略通过引入锚定组优势来优化优势估计,并采用复杂度自适应动态展开机制高效分配探索预算,有效赋能紧凑模型掌握基于执行的优化逻辑。基于Qwen3模型实现的LASER在执行效率上显著超越规则系统与LLM,同时以极低开销展现出强大的零样本迁移能力。

0
下载
关闭预览

相关内容

SQL 全名是结构化查询语言,是用于数据库中的标准数据查询语言,IBM 公司最早使用在其开发的数据库系统中。
什么是后训练?大语言模型训练后优化方法综述,87页pdf
【MIT博士论文】数据高效强化学习,176页pdf
高效的文本生成方法 — LaserTagger 现已开源
TensorFlow
30+阅读 · 2020年2月27日
基于MySQL Binlog的Elasticsearch数据同步实践
DBAplus社群
15+阅读 · 2019年9月3日
一种关键字提取新方法
1号机器人网
21+阅读 · 2018年11月15日
国家自然科学基金
1+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 4月23日
Arxiv
0+阅读 · 3月30日
Arxiv
0+阅读 · 3月20日
VIP会员
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
8+阅读 · 6月17日
定向能反无人机系统最新发展动态
专知会员服务
10+阅读 · 6月17日
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
6+阅读 · 6月17日
相关基金
国家自然科学基金
1+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员