【发布时间】:2016-06-25 16:41:12
【问题描述】:
我有一个运行代码大约需要 20 秒的存储过程。当我将代码直接复制到 SSMS 中时,它会在
我已经阅读了参数嗅探,并更改了我的代码来处理这个问题,没有影响。我还尝试了在调用主存储过程和调用所有其他存储过程时的“with recompile”提示,这让它变慢了。
还能是什么?
所以我的调用存储过程如下所示:
CREATE PROCEDURE [dbo].[spr_DoPersonMatch]
@inPmq_ID bigint -- Passed in pending match ID
AS
BEGIN
SET NOCOUNT ON;
declare @pmq_ID bigint
set @pmq_ID = @inPmq_ID
declare @Total_match_count as int = 0
declare @match_rule as int
declare @AuditMatch as bit = 0
-- Match Rule 1 - FORENAME & SURNAME & NINO & either (NHSNO or UPN)
exec dbo.spr_DoPersonMatchRule1 @pmq_ID,@AuditMatch ,@match_count = @Total_match_count output
if @Total_match_count > 0 set @match_rule = 1
-- Match Rule 2 - FORENAME & SURNAME & NINO & either (NHSNO or UPN)
if @Total_match_count < 1 -- If we have a match, do not do any more matches. Drop through
BEGIN
exec dbo.spr_DoPersonMatchRule2 @pmq_ID,@AuditMatch ,@match_count = @Total_match_count output
if @Total_match_count > 0 set @match_rule = 2
END
正如我所说,如果我将上面的主存储过程代码复制到 SSMS 中并运行它(在代码顶部设置 inPmq_ID),它会立即运行。
我缺少什么吗?
【问题讨论】:
标签: sql-server-2008 stored-procedures sqlperformance