Does every column contained in a composite FK need

2019-08-03 21:24发布

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?

2条回答
劳资没心,怎么记你
2楼-- · 2019-08-03 22:10

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.

查看更多
Animai°情兽
3楼-- · 2019-08-03 22:21

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

查看更多
登录 后发表回答