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
期刊:
影响因子:
--
通讯作者:
Kwanghyun Park
中科院分区:
文献类型:
--
作者:
Karthik Ramachandra;Kwanghyun Park
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'.