1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-22 12:15:36 +01:00

join optimizations

This commit is contained in:
Kyle Spearrin 2017-04-15 10:52:38 -04:00
parent c6dcac96d3
commit 8e193dfc62
2 changed files with 8 additions and 3 deletions

View File

@ -9,7 +9,7 @@ BEGIN
FROM FROM
[dbo].[CipherDetails](@UserId) C [dbo].[CipherDetails](@UserId) C
LEFT JOIN LEFT JOIN
[dbo].[SubvaultCipher] SC ON SC.[CipherId] = C.[Id] [dbo].[SubvaultCipher] SC ON C.[UserId] IS NULL AND SC.[CipherId] = C.[Id]
LEFT JOIN LEFT JOIN
[dbo].[SubvaultUser] SU ON SU.[SubvaultId] = SC.[SubvaultId] [dbo].[SubvaultUser] SU ON SU.[SubvaultId] = SC.[SubvaultId]
LEFT JOIN LEFT JOIN

View File

@ -24,7 +24,12 @@ BEGIN
WHERE WHERE
C.Id = @Id C.Id = @Id
AND ( AND (
(C.[UserId] IS NOT NULL AND C.[UserId] = @UserId) C.[UserId] = @UserId
OR (OU.[UserId] = @UserId AND OU.[Status] = 2 AND O.[Enabled] = 1) -- 2 = Confirmed OR (
C.[UserId] IS NULL
AND OU.[UserId] = @UserId
AND OU.[Status] = 2 -- 2 = Confirmed
AND O.[Enabled] = 1
)
) )
END END