0

I am using SQL Server.

Is it needed to use index for any foreign key for improving speed?

Or will SQL Server do it automatically when I define foreign keys?

1

1 Answer 1

2

SQL Server will not automatically add an index when creating a foreign key. An index on that foreign key may help improve performance. But usually there are more columns needed from that table, so it might be a better decision to add a few more columns needed (either being part of the index or as included columns).

Sign up to request clarification or add additional context in comments.

2 Comments

More specific note: Indexing foreign key columns mainly speeds up DELETE operations, as it can quickly tell if the row can be deleted without having to scan other tables.
@pmbAustin: and having an index on the foreign key column also helps with JOIN operations, since the FK data can be read in sorted order!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.