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

index tuning script

This commit is contained in:
Kyle Spearrin 2017-11-13 08:53:25 -05:00
parent aa045f7775
commit 39baf2a9be
3 changed files with 49 additions and 0 deletions

View File

@ -15,3 +15,9 @@
CONSTRAINT [FK_OrganizationUser_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id])
);
GO
CREATE NONCLUSTERED INDEX [IX_OrganizationUser_UserIdOrganizationIdStatus]
ON [dbo].[OrganizationUser]([UserId] ASC, [OrganizationId] ASC, [Status] ASC)
INCLUDE ([AccessAll]);

View File

@ -0,0 +1,42 @@
IF EXISTS (
SELECT * FROM sys.indexes WHERE [Name]='IX_Cipher_UserId_Type'
AND object_id = OBJECT_ID('[dbo].[Cipher]')
)
BEGIN
DROP INDEX [IX_Cipher_UserId_Type] ON [dbo].[Cipher]
END
GO
IF NOT EXISTS (
SELECT * FROM sys.indexes WHERE [Name]='IX_Cipher_UserId_Type_IncludeAll'
AND object_id = OBJECT_ID('[dbo].[Cipher]')
)
BEGIN
CREATE NONCLUSTERED INDEX [IX_Cipher_UserId_Type_IncludeAll]
ON [dbo].[Cipher]([UserId] ASC, [Type] ASC)
INCLUDE ([OrganizationId], [Data], [Favorites], [Folders], [Attachments], [CreationDate], [RevisionDate])
END
GO
IF NOT EXISTS (
SELECT * FROM sys.indexes WHERE [Name] = 'IX_Folder_UserId_IncludeAll'
AND object_id = OBJECT_ID('[dbo].[Folder]')
)
BEGIN
CREATE NONCLUSTERED INDEX [IX_Folder_UserId_IncludeAll]
ON [dbo].[Folder]([UserId] ASC)
INCLUDE ([Name], [CreationDate], [RevisionDate])
END
GO
IF NOT EXISTS (
SELECT * FROM sys.indexes WHERE [Name] = 'IX_OrganizationUser_UserIdOrganizationIdStatus'
AND object_id = OBJECT_ID('[dbo].[OrganizationUser]')
)
BEGIN
CREATE NONCLUSTERED INDEX [IX_OrganizationUser_UserIdOrganizationIdStatus]
ON [dbo].[OrganizationUser]([UserId] ASC,[OrganizationId] ASC,[Status] ASC)
INCLUDE ([AccessAll])
END
GO

View File

@ -8,6 +8,7 @@
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="DbScripts\2017-11-13_IndexTuning.sql" />
<EmbeddedResource Include="DbScripts\2017-11-06_00_FamilyPlanAdjustments.sql" />
<EmbeddedResource Include="DbScripts\2017-10-25_00_OrgUserUpdates.sql" />
<EmbeddedResource Include="DbScripts\2017-09-08_00_OrgUserCounts.sql" />