Does every column contained in a composite FK need

2019-08-03 21:46发布

问题:

I usually put index on my FKs to speeds up my queries, but what if I have a grouped index on two columns which one of them is FK. Is it necessary to put index on it too?

As you may know, in this condition dm_db_missing_index_details keeps suggesting one missing index.

I would appreciate if anybody could tell if it's really necessary or not?

回答1:

Only if the composite index has the FK as the leftmost key. An index on (FK, Foo) will cover the (FK) missing index. But an index on (Foo, FK) will be useless.



回答2:

You really do not need an index, but as you said it will speed up a query process.