arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2506.02802cs.DBcs.LG
收藏

一种基于学习成本模型的SQL工作负载跨引擎优化器

A Learned Cost Model-based Cross-engine Optimizer for SQL Workloads

IBM Research(IBM研究院)

András Strausz, Niels Pardon, Ioana Giurgiu

AI总结:

本文提出一种基于学习成本模型的跨引擎优化器,通过多任务学习和查询计划自动为SQL工作负载选择最优执行引擎,实验表明可显著降低Q-error并减少总运行时间。

摘要:

Lakehouse系统使得同一数据能够被多个执行引擎查询。然而,选择最适合运行SQL查询的引擎仍然需要事先了解查询的计算需求和引擎能力,这是一项复杂且需要人工完成的任务,并且随着新引擎和新工作负载的出现,这一任务只会变得更加困难。本文针对这一局限性,提出了一种跨引擎优化器,能够通过学习得到的成本模型为多样化的SQL查询自动选择引擎。在提示(hints)的优化下,查询计划被用于查询成本预测和路由。成本预测被形式化为一个多任务学习问题,模型架构中使用了多个预测头,分别对应不同的引擎和资源配置。这消除了训练特定引擎模型的需要,并允许以极低的微调成本灵活添加新引擎。在多个数据库和引擎上的结果表明,与使用未优化计划作为输入相比,使用查询优化后的逻辑计划进行成本估计可将平均Q-error降低多达12.6%。此外,与随机路由相比,所提出的跨引擎优化器在零样本(zero-shot)设置下将总工作负载运行时间最多减少25.2%,在少样本(few-shot)设置下最多减少30.4%。

英文摘要:

Lakehouse systems enable the same data to be queried with multiple execution engines. However, selecting the engine best suited to run a SQL query still requires a priori knowledge of the query computational requirements and an engine capability, a complex and manual task that only becomes more difficult with the emergence of new engines and workloads. In this paper, we address this limitation by proposing a cross-engine optimizer that can automate engine selection for diverse SQL queries through a learned cost model. Optimized with hints, a query plan is used for query cost prediction and routing. Cost prediction is formulated as a multi-task learning problem, and multiple predictor heads, corresponding to different engines and provisionings, are used in the model architecture. This eliminates the need to train engine-specific models and allows the flexible addition of new engines at a minimal fine-tuning cost. Results on various databases and engines show that using a query optimized logical plan for cost estimation decreases the average Q-error by even 12.6% over using unoptimized plans as input. Moreover, the proposed cross-engine optimizer reduces the total workload runtime by up to 25.2% in a zero-shot setting and 30.4% in a few-shot setting when compared to random routing.

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

↑