SqlServer - OPTION RECOMPILE 并行执行行为

SqlServer - OPTION RECOMPILE parallel execution behavior

我需要说明当您使用 OPTION RECOMPILE 并行执行参数化过程时 SQLServer 的行为。

选项重新编译: "You can force SQL Server to recompile the stored procedure each time it is run. The benefit here is that the best query plan will be created each time it is run."

我的问题是,在并行中执行此过程时, 是为每个执行的并发过程创建最佳查询计划还是使用 1 个计划?

将为并行执行的每个并发过程创建最佳查询计划。

此计划仅供会话使用,不会添加到计划缓存中。

如果计划可以在会话之间使用,那将是一个错误,因为 OPTION (RECOMPILE) 可以根据通常不适用于所有可能参数值的参数值执行简化。