Does every column contained in a composite FK need an extra Index on it?

倾然丶 夕夏残阳落幕 提交于 2019-12-11 12:55:34

问题


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.



来源:https://stackoverflow.com/questions/13361178/does-every-column-contained-in-a-composite-fk-need-an-extra-index-on-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!