Skip to content

Instantly share code, notes, and snippets.

@BrentOzar
Created September 3, 2017 12:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrentOzar/b4d6a6776d47084d71f467db1eb4ac10 to your computer and use it in GitHub Desktop.
Save BrentOzar/b4d6a6776d47084d71f467db1eb4ac10 to your computer and use it in GitHub Desktop.
Creating basic indexes on the public Stack Overflow database export
CREATE INDEX IX_UserId ON dbo.Badges(UserId);
GO
CREATE INDEX IX_PostId ON dbo.Comments(PostId);
GO
CREATE INDEX IX_UserId ON dbo.Comments(UserId);
GO
CREATE INDEX IX_PostId ON dbo.PostLinks(PostId);
GO
CREATE INDEX IX_RelatedPostId ON dbo.PostLinks(RelatedPostId);
GO
CREATE INDEX IX_LinkTypeId ON dbo.PostLinks(LinkTypeId);
GO
CREATE INDEX IX_AcceptedAnswerId ON dbo.Posts(AcceptedAnswerId);
GO
CREATE INDEX IX_LastEditorUserId ON dbo.Posts(LastEditorUserId);
GO
CREATE INDEX IX_OwnerUserId ON dbo.Posts(OwnerUserId);
GO
CREATE INDEX IX_ParentId ON dbo.Posts(ParentId);
GO
CREATE INDEX IX_PostTypeId ON dbo.Posts(PostTypeId);
GO
CREATE INDEX IX_PostId ON dbo.Votes(PostId);
GO
CREATE INDEX IX_UserId ON dbo.Votes(UserId);
GO
CREATE INDEX IX_VoteTypeId ON dbo.Votes(VoteTypeId);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment