我有一个在Azure中的经典服务实例上运行的WCF服务。该服务使用Azure SQL数据库。
请求处理时间太长。
这是端到端交易的屏幕截图。我突出了对数据库的两个缓慢调用。
当我在Azure门户上查看“查询性能见解”时,发现这是最耗时的查询:
(@p__linq__0 nvarchar(4000),@p__linq__1 uniqueidentifier)SELECT
[Limit1].[ObfuscationType] AS [ObfuscationType],
[Limit1].[Id] AS [Id],
[Limit1].[Obfuscationsnummer] AS [Obfuscationsnummer],
[Limit1].[Object] AS [Object],
[Limit1].[Status] AS [Status],
[Limit1].[Organisation_CloudApiKey] AS [Organisation_CloudApiKey]
FROM ( SELECT TOP (1)
[Extent1].[Id] AS [Id],
[Extent1].[Obfuscationsnummer] AS [Obfuscationsnummer],
[Extent1].[ObfuscationType] AS [ObfuscationType],
[Extent1].[Object] AS [Object],
[Extent1].[Status] AS [Status],
[Extent1].[Organisation_CloudApiKey] AS [Organisation_CloudApiKey]
FROM [dbo].[CloudObject] AS [Extent1]
WHERE (([Extent1].[Obfuscationsnummer] = @p__linq__0)
OR (([Extent1].[Obfuscationsnummer] IS NULL)
AND (@p__linq__0 IS NULL)))
AND ([Extent1].[Organisation_CloudApiKey] = @p__linq__1)
) AS [Limit1]
现有索引
表上有三个现有索引:
IX_Organisation_CloudApiKey:
在[dbo]上创建NONCLUSTERED索引[IX_Organisation_CloudApiKey]。[CloudObject] ( [Organisation_CloudApiKey] ASC )与[STATISTICS_NORECOMPUTE = OFF,DROP_EXISTING = OFF,ONLINE = OFF)一起开启[PRIMARY] 开始
Azure自动生成的密钥:
在[dbo]上创建NONCLUSTERED索引[nci_wi_CloudObject_7AD41B9985003F79D674]。[CloudObject] ( [Organisation_CloudApiKey] ASC ) 包含([Obfuscationsnummer]),其中(STATISTICS_NORECOMPUTE = OFF,DROP_EXISTING = OFF,ONLINE = OFF)开启[主] 开始
主键
问题
如何使该查询的性能更好?