The Key to Effective UDF Optimization: Before Inlining, First Perform Outlining

Although user-defined functions (UDFs) are a popular way to augment SQL's declarative approach with procedural code, the mismatch between programming paradigms creates a fundamental optimization challenge. UDF inlining automatically removes all UDF calls by replacing them with equivalent SQL subqueries. Although inlining leaves queries entirely in SQL (resulting in large performance gains), we observe that inlining the entire UDF often leads to sub-optimal performance. A better approach is to analyze the UDF, deconstruct it into smaller pieces, and inline only the pieces that help query optimization. To achieve this, we propose UDF outlining, a technique to intentionally hide pieces of a UDF from the optimizer, resulting in simpler UDFs and significantly faster query plans. Our implementation (PRISM) demonstrates that UDF outlining improves performance over conventional inlining (on average 1.29× speedup for DuckDB and 298.73× for SQL Server) through a combination of more effective unnesting, improved data skipping, and by avoiding unnecessary joins.

Authors

Institutions

Publication Details

Journal
Proceedings of the VLDB Endowment
Published
2024-09-01
DOI
https://doi.org/10.14778/3696435.3696436
Citations
3
Primary Topic
Cardiovascular Syncope and Autonomic Disorders
Type
article
Field-Weighted Citation Impact
1.72
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

The Key to Effective UDF Optimization: Before Inlining, First Perform Outlining

Samuel Arch, Andrew Pavlo, Jignesh M. Patel, Todd C. Mowry et al.
3 citations
Proceedings of the VLDB Endowment
Cardiovascular Syncope and Autonomic Disorders
1.72
article

The Key to Effective UDF Optimization: Before Inlining, First Perform Outlining

Samuel Arch, Andrew Pavlo, Jignesh M. Patel, Todd C. Mowry, Yuchen Liu
article en
3 citations

Abstract

Although user-defined functions (UDFs) are a popular way to augment SQL's declarative approach with procedural code, the mismatch between programming paradigms creates a fundamental optimization challenge. UDF inlining automatically removes all UDF calls by replacing them with equivalent SQL subqueries. Although inlining leaves queries entirely in SQL (resulting in large performance gains), we observe that inlining the entire UDF often leads to sub-optimal performance. A better approach is to analyze the UDF, deconstruct it into smaller pieces, and inline only the pieces that help query optimization. To achieve this, we propose UDF outlining, a technique to intentionally hide pieces of a UDF from the optimizer, resulting in simpler UDFs and significantly faster query plans. Our implementation (PRISM) demonstrates that UDF outlining improves performance over conventional inlining (on average 1.29× speedup for DuckDB and 298.73× for SQL Server) through a combination of more effective unnesting, improved data skipping, and by avoiding unnecessary joins.

Proceedings of the VLDB EndowmentVol. 18(1)
Carnegie Mellon University (US)
Openalex Percentile: Top 14%
Cardiovascular Syncope and Autonomic Disorders
1.72
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.