在审核了 SQL 查询后,我们注意到我们的一些最昂贵的查询是由LOWER
使用该函数的 .net 身份验证框架进行的(参见下面的示例)
我们的数据库不区分大小写,因此这会造成不必要的性能损失。
我正在寻找更改这些查询的最简单方法,我假设我需要使用某种自定义成员资格提供程序。
SELECT TOP (1)
1 AS [C1],
[Extent1].[UserName] AS [UserName],
[Extent1].[UserId] AS [UserId],
[Extent2].[Email] AS [Email],
[Extent2].[PasswordQuestion] AS [PasswordQuestion],
[Extent2].[Comment] AS [Comment],
[Extent2].[IsApproved] AS [IsApproved],
[Extent2].[IsLockedOut] AS [IsLockedOut],
[Extent2].[CreateDate] AS [CreateDate],
[Extent2].[LastLoginDate] AS [LastLoginDate],
[Extent1].[LastActivityDate] AS [LastActivityDate],
[Extent2].[LastPasswordChangedDate] AS [LastPasswordChangedDate],
[Extent2].[LastLockoutDate] AS [LastLockoutDate]
FROM [dbo].[Users] AS [Extent1]
INNER JOIN [dbo].[Memberships] AS [Extent2] ON [Extent2].[UserId] = [Extent1].[UserId]
INNER JOIN [dbo].[Applications] AS [Extent3] ON [Extent3].[ApplicationId] = [Extent2].[ApplicationId]
WHERE ((LOWER([Extent3].[ApplicationName])) = @appName) AND ((LOWER([Extent1].[UserName]))
= @userName)