The history of UDF optimization in relational databases reads as a story of increasing transparency 2. Compilation makes UDFs faster but leaves them opaque to the optimizer. Batching and fusion amortize invocation costs but still treat UDFs as black boxes. Inlining, most notably demonstrated by Microsoft's FROID system 3, aspires to the ultimate transparency by converting UDFs entirely into SQL, hence letting the optimizer reason about their contents. The trajectory seems inevitable: the path to better performance runs through making everything visible.
Alkis Simitsis (Thu,) studied this question.