我正在尝试在我们的网站上将下面的存储过程调整为每分钟 30k 次。
CREATE PROCEDURE [dbo].[mltHttpCallStatus]
@SupplierId AS INTEGER,
@CallIsGood AS BIT,
@MaxWorkerThreads AS INT,
@MaxIOThreads AS INT,
@AvailWorkerThreads AS INT,
@AvailIOThreads AS INT,
@ScriptTypeId AS INT,
@SiteTypeId AS VARCHAR(50),
@ConnectionTime AS INT,
@SiteName AS VARCHAR(50),
@HostName AS VARCHAR(50)
AS
--DEBUG BEN (Flight details keep failing) 07012008 19:30
--Return
SET NOCOUNT ON
DECLARE @GoodCalls AS INT,
@BadCalls AS INT
SET @BadCalls = 0
SET @GoodCalls = 0
IF @CallIsGood = 1
SET @GoodCalls = 1
ELSE
SET @BadCalls = 1
UPDATE HttpCallStatus_tbl SET
GoodCalls = GoodCalls + @GoodCalls,
BadCalls = BadCalls + @BadCalls,
TotalConnectionTime = TotalConnectionTime + @ConnectionTime
--WHERE dbo.datepart_fn(DayDate) = dbo.datepart_fn(getDate())
WHERE DATEADD(dd, 0, DATEDIFF(dd, 0, DayDate)) = DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))
AND DATEPART(HOUR, DayDate) = DATEPART(HOUR, getDate())
AND SupplierId = @SupplierId
AND ScriptTypeId = @ScriptTypeId
AND SiteTypeId = @SiteTypeId
AND SiteName = @SiteName
AND HostName = @HostName
IF @@ROWCOUNT = 0
BEGIN
INSERT INTO HttpCallStatus_tbl (DayDate,SupplierId,GoodCalls,BadCalls,ScriptTypeId,SiteTypeId,TotalConnectionTime,
MaxWorkerThreads,MaxIOThreads,AvailWorkerThreads,AvailIOThreads,SiteName,HostName)
VALUES (CONVERT(DATETIME, getDate(), 103),
@SupplierId,
@GoodCalls,
@BadCalls,
@ScriptTypeId,
@SiteTypeId,
@ConnectionTime,
0,
0,
0,
0,
@SiteName,
@HostName)
END
表结构
Column_name Type Length
DayDate datetime 8
SupplierId int 4
GoodCalls int 4
BadCalls int 4
ScriptTypeId int 4
SiteTypeId varchar 50
TotalConnectionTime int 4
MaxWorkerThreads int 4
MaxIOThreads int 4
AvailWorkerThreads int 4
AvailIOThreads int 4
SiteName varchar 50
HostName varchar 50
SearchCount int 4
DomainId int 4
索引
[PK_HttpCallStatus_tbl] clustered, unique, primary key [DayDate],[SupplierId]
[IX_HttpCallStatus_tbl] nonclustered [SupplierId]
[idx_HttpCallStatus_tbl_1] nonclustered
[SupplierId], [ScriptTypeId], [SiteTypeId], [SiteName], [HostName]
, [DayDate], [GoodCalls], [BadCalls], [TotalConnectionTime]
我注意到这些变量是未使用的@MaxWorkerThreads、@MaxIOThreads、@AvailWorkerThreads、@AvailIOThreads。也可以使变量@goodcalls & @Badcalls TINYINTS。我还在插入语句 VALUES (CONVERT(DATETIME, getDate(), 103) 中注意到了这种转换。但我认为这是默认值,因此可以更改为 Getdate()
我的问题是很难衡量改进,因为它们都非常快,我是否值得进行这些更改,我什至会看到一点点收获吗?