BlackMagic: Automatic Inlining of Scalar UDFs into SQL Queries with Froid

BlackMagic: Automatic Inlining of Scalar UDFs into SQL Queries with Froid
复制标题

BlackMagic:使用 Froid 将标量 UDF 自动内联到 SQL 查询中

DOI:
10.14778/3352063.3352072
复制
发表时间:
2019
期刊:
Proc. VLDB Endow.
影响因子:
--
通讯作者:
Kwanghyun Park
Kwanghyun Park
中科院分区:
--
文献类型:
--
作者:
Karthik Ramachandra;Kwanghyun Park

文献摘要

被引文献

相似文献

关系 DBMS 允许用户使用实现自定义行为的用户定义函数 (UDF) 来扩展标准声明式 SQL 语言表面。虽然 UDF 具有许多优点,但从业者众所周知,它们可能会导致查询性能严重下降。这种降级是由于最先进的查询优化器将 UDF 视为黑匣子并且在优化期间不会对它们进行推理。 我们演示了 Froid,这是一个通过打开这个黑匣子并将其底层操作暴露给查询优化器来优化 UDF 的框架。它通过系统地将命令式多语句 UDF 的整个主体转换为单个关系代数表达式来实现这一点。因此,调用此 UDF 的任何查询都将转换为具有语义上与 UDF 等效的嵌套子查询的查询。然后,我们利用现有的子查询优化技术,从而获得高效、面向集合的并行查询计划,而不是低效、迭代、串行执行 UDF。 我们展示了 Froid 的优势,包括在实际工作负载上实现高达多个数量级的性能提升。 Froid 作为 Microsoft SQL Server 2019 的一项功能提供,称为“标量 UDF 内联”。
Relational DBMSs allow users to extend the standard declarative SQL language surface using User Defined Functions (UDFs) that implement custom behavior. While UDFs offer many advantages, it is well-known amongst practitioners that they can cause severe degradation in query performance. This degradation is due to the fact that state-of-the-art query optimizers treat UDFs as black boxes and do not reason about them during optimization. We demonstrate Froid, a framework for optimizing UDFs by opening up this black box and exposing its underlying operations to the query optimizer. It achieves this by systematically translating the entire body of an imperative multi-statement UDF into a single relational algebraic expression. Thereby, any query invoking this UDF is transformed into a query with a nested sub-query that is semantically equivalent to the UDF. We then leverage existing sub-query optimization techniques and thereby get efficient, set-oriented, parallel query plans as opposed to inefficient, iterative, serial execution of UDFs. We demonstrate the benefits of Froid including performance gains of up to multiple orders of magnitude on real workloads. Froid is available as a feature of Microsoft SQL Server 2019 called 'Scalar UDF Inlining'.