BT

SQL Server 2016: Natively Compiled Functions

| by Jonathan Allen Follow 635 Followers on Jun 08, 2015. Estimated reading time: 1 minute |

Server 2014 saw the introduction of Natively Compiled Stored Procedures. In 2016 we’ll be able to do the same for Scalar User Defined Functions (Scalar UDF).

In SQL Server, normal T-SQL is compiled into a proprietary intermediate language. That intermediate language is then interpreted at run time. With native compilation, the stored procedure is converted into C code, which is then compiled into a DLL that SQL Server uses at run time.

A Scalar UDF can now be compiled to machine code in a similar manner. For simple operations, this should result in a significant performance improvement. Natively compiled Scalar UDFs can be used anywhere normal Scalar UDFs can be used. Beyond that, they can also be used in Natively Compiled Stored Procedures. This is a huge win for code reusability, which has historically meant poor performance in SQL Server.

Like Natively Compiled Stored Procedures, Natively Compiled Scalar UDFs must be declared as schema bound. With stored procedures, the WITH SCHEMABINDING option indicates that native compilation is desired. It is unclear how that will work with UDFs, as you can have interpreted, schema-bound functions. Perhaps it will automatically detect whether or not a schema bound UDF is a candidate for native compilation and react accordingly.

 

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss
BT