存储过程需要80秒才能执行

时间:2017-01-30 15:38:14

标签: sql sql-server stored-procedures sqlprofiler

与其他存储过程相比,我的存储过程似乎占用了太长时间。我已经运行了一个SQL分析器,这需要80秒才能通过ASP.NET应用程序在某些情况下返回数据,存储过程是否有问题?

USE [Payments]
GO
/****** Object:  StoredProcedure [dbo].[liftsGetByCustomerNumber]    Script Date: 30/01/2017 15:35:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



ALTER PROCEDURE [dbo].[liftsGetByCustomerNumber] 

    @mprn BIGINT,
    @startDate DATE,
    @endDate DATE,
    @customerNumber nVarChar(50)


AS
BEGIN

SELECT b.[transactionId]
      ,b.[accountGUID]
      ,b.[transactionDate]
      ,b.[transactionAmount]
      ,b.[transactionType]
      ,b.[transactionDeposit]
FROM accounts  as a,transactions as b
where a.GUID = b.accountGUID
and  a.mprn = @mprn
and a.customernumber = @customerNumber
and b.transactionDate between @startdate and @enddate
and b.transactionAmount > 0
and b.transactionType not in ('00','0', '0N', '99')
order by transactionDate, transactionType
END

表中只有80,000个账户和200,000个交易,所以我无法预见到这么慢,我还能检查其他什么问题?

0 个答案:

没有答案