What factors can cause Stored Procedure Recompilation on SQL Server?

前端 未结 3 629
长发绾君心
长发绾君心 2020-12-19 09:03

What factors should I be aware of that can cause excessive stored procedure recompilation?

Examples of the code that will cause a stored procedure to recompile would

3条回答
  •  余生分开走
    2020-12-19 09:40

    Certain SET options can cause stored procedure recompilation or even multiple recompilations in one execution!

    Some of these options may be not even inside the SP

    --this will cause recompilation
    SET concat_null_yields_null ON;
    EXEC spMyProc;
    

    Some of the options that cause recompilation when inside the SP:

    ARITHABORT

    ANSI_NULLS

    QUOTED_IDENTIFIER

    Luckily, this one doesn't cause the recompilation: SET NOCOUNT ON;

提交回复
热议问题