SQL query rewriting is a well-established technique for improving database performance without schema or index changes, yet finding effective rewrites for modern analytical workloads remains difficult: rule-based methods are limited to predefined transformations, while LLM-based approaches often produce rewrites that are semantically valid but compile to equivalent physical plans or degrade runtime performance. We present SPA, a SQL-Plan-Aware reinforcement learning framework that trains LLMs to rewrite queries using physical execution feedback. SPA formulates rewriting as a policy optimization problem and extends GRPO with rewards spanning semantic equivalence, textual rewrite distance, physical-plan divergence, and runtime speedup. To handle reward sparsity across query difficulty, SPA introduces Probability-Gated Adaptive Reward Shaping, a query-level curriculum that unlocks higher-level rewards only once a rollout group achieves sufficient mastery of lower-level objectives, and further improves sample efficiency through on-policy self-improvement by recycling slowdown rewrites from the current policy as targeted training signals. On both IID and OOD workloads, SPA outperforms rule-based and strong LLM baselines in end-to-end runtime, substantially reduces harmful slowdown rewrites, and yields strong tail-latency gains.
Prompt as a Data Type: In-Database LLM Prompt Management and Rewriting
Department of Computing and Mathematics University of Sao Paulo(计算机与数学系 乌拉圭圣保罗大学);Department of Information Systems University of Münster(信息系统系 梅茵斯特大学)
A comparative analysis of state-of-the-art SQL-on-Hadoop systems for interactive analytics
Hadoop正在成为企业中的主要数据中心,而SQL代表了事实上的数据分析语言。这种结合导致了当今使用的各种SQL-on-Hadoop系统的开发。虽然各种SQL-on-Hadoop系统针对同一类分析工作负载,但它们不同的架构、设计决策和实现会影响查询性能。在这项工作中,我们使用Amazon EC2云平台上的Web Data Analytics微基准和TPC-H基准对四个最先进的SQL on Hadoop系统(Impala,Drill,Spark SQL和Phoenix)进行了比较分析。TPC-H实验结果表明,尽管Impala在文本格式上优于其他系统(4.41 x-6.65 x),但在镶木格式中存在权衡,每个系统在查询子集上表现最好。对执行配置文件的全面分析扩展了性能结果,以深入了解性能变化、性能瓶颈和查询执行特性。
ErrorLLM: Modeling SQL Errors for Text-to-SQL Refinement
The Hong Kong Polytechnic University(香港理工大学);City University of Macau(澳门城市大学);Jilin University(吉林大学);Harbin Institute of Technology (Shenzhen)(哈尔滨工业大学(深圳));Beihang University(北航大学)
Query Carefully: Detecting the Unanswerables in Text-to-SQL Tasks
Institute of Computer Science, Zurich University of Applied Sciences(计算机科学研究所,应用科学大学苏黎世);Institute of Medical Virology, University of Zurich(医学病毒学研究所,苏黎世大学);Department of Gastroenterology and Hepatology, University Hospital Zurich, University of Zurich(消化内科与肝病科,苏黎世大学医院,苏黎世大学)