/ Published in: C#
When you add a Foreign Key Relationship in MS SQL you should always add a index as well for performance. This seems like it should be almost done automatically but its not.
Expand |
Embed | Plain Text
ALTER TABLE [dbo].[sarg_PM_StatusHistory] WITH NOCHECK ADD CONSTRAINT [FK_sarg_PM_StatusHistory_sarg_PM_LOC] FOREIGN KEY([locID]) REFERENCES [dbo].[sarg_PM_LOC] ([locID]) ON UPDATE CASCADE ON DELETE CASCADE GO ALTER TABLE [dbo].[sarg_PM_StatusHistory] CHECK CONSTRAINT [FK_sarg_PM_StatusHistory_sarg_PM_LOC] GO /****** Object: Index [IX_sarg_PM_StatusHistory] Script Date: 02/05/2010 09:29:47 ******/ CREATE NONCLUSTERED INDEX [IX_sarg_PM_StatusHistory] ON [dbo].[sarg_PM_StatusHistory] ( [locID] ASC, [status] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] GO
You need to login to post a comment.
