March 15, 2010 at 11:40 am
Howdy,
For some reason my understanding was that creating an FK constraint also created an index, but after looking at the table I'm not sure.
Can anyone clarify this or point me in the right direction - do I need to create a NC index and FK constraint, or just FK?
Thanks,
Scott
March 15, 2010 at 11:41 am
No, creating a FK does not create an index on the same column(s). If you want an index on your FK column(s), you must explicitly create it.
March 15, 2010 at 11:45 am
Good to know, thanks for the quick reply.
Regards,
Scott
March 15, 2010 at 11:55 am
This is actually a common misconception. As John said, you will need to create an index manually for each FK.
Also of worth, I covered this topic with a script in a recent blog article.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
March 15, 2010 at 12:47 pm
Probably a misconception due to the fact that a Primary Key DOES add a unique index by nature.
March 15, 2010 at 12:52 pm
David Nash-367764 (3/15/2010)
Probably a misconception due to the fact that a Primary Key DOES add a unique index by nature.
That probably is true.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
March 15, 2010 at 5:22 pm
Thanks - yes i found a script (could be yours) that identifies the FKs without indexes. I just used it not to long ago. I think I just had a case of the Mondays...
March 15, 2010 at 5:25 pm
You're welcome.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
March 16, 2010 at 4:51 am
Well - it depends. If you use the diagramming tool to set up your FKs it will automatically generate indexes.
Except when it breaks when you're saving. Then you can find it actually removes existing ones
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply