Skip to content

Instantly share code, notes, and snippets.

@philip-paolo
Last active July 20, 2022 10:31
Show Gist options
  • Save philip-paolo/1c49f25ae1129a1ca3fa4f86b57d9084 to your computer and use it in GitHub Desktop.
Save philip-paolo/1c49f25ae1129a1ca3fa4f86b57d9084 to your computer and use it in GitHub Desktop.
Performance tuning
-- Dropping PK and creating new PK with CompanyID, ID to align with policy
ALTER TABLE [dbo].[ContactLists] DROP CONSTRAINT [PK_ContactLists] WITH ( ONLINE = OFF )
GO
ALTER TABLE [dbo].[ContactLists] ADD CONSTRAINT PK_ContactLists PRIMARY KEY CLUSTERED ([CompanyID] ASC, [ID] ASC)
GO
-- Preserve fast lookup on ID
CREATE UNIQUE INDEX [IX_ContactLists_ID] ON [dbo].[ContactLists] ([ID])
GO
-- Performance tuning - missing index
CREATE NONCLUSTERED INDEX [IX_ContactNotifications_Processed] ON [dbo].[ContactNotifications] ([Processed]) INCLUDE ([ListID])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment