Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL server - Difference between Natively Compiled Stored Procedure and ordinary stored procedure

As always I used to create ordinary stored procedures regarding the second option for creating stored procedure called "Natively Compiled Stored Procedure" I wanna know if there is any performance benefit to using compiled one?

Is there anyone can Help to find out? Thanks

like image 622
msd Avatar asked Jul 01 '17 11:07

msd


People also ask

What is natively compiled stored procedures in SQL Server?

A natively compiled stored procedure is compiled when it is created, rather than when it is executed. That compile process first translates the store procedure code into “C”, and then into machine language and stores the code as a DLL. The DLL is stored in a special folder on the SQL Server machine.

What is natively compiled?

What Does Native Compiler Mean? A native compiler is a compiler that works on compilation for the same technology on which it runs. It uses the same operating system or platform as the software for which it is assembling machine language.

What is native stored procedure?

A native SQL procedure is a procedure whose body is written entirely in SQL. The body is written in the SQL procedural language (SQL PL). A native SQL procedure is created by issuing a single SQL statement, CREATE PROCEDURE.

What happens when a stored procedure is compiled?

When a procedure is compiled for the first time or recompiled, the procedure's query plan is optimized for the current state of the database and its objects. If a database undergoes significant changes to its data or structure, recompiling a procedure updates and optimizes the procedure's query plan for those changes.


1 Answers

Stored procedures that are marked with NATIVE_COMPILATION are natively compiled. This means the Transact-SQL statements in the procedure are all compiled to native code for efficient execution of performance-critical business logic.

For more information, see Native Compilation of Tables and Stored Procedures

like image 54
Mustafa taha Avatar answered Oct 02 '22 01:10

Mustafa taha