Should every SQL Server foreign key have a matching index?

前端 未结 4 984
粉色の甜心
粉色の甜心 2020-12-04 16:10

Is it good practice to create an index for every foreign key in a SQL Server database?

4条回答
  •  悲&欢浪女
    2020-12-04 16:47

    Every foreign key? No. Where the selectivity is low (i.e. many values are duplicated), an index may be more costly than a table scan. Also, in a high activity environment (much more insert/update/delete activity than querying) the cost of maintaining the indexes may affect the overall performance of the system.

提交回复
热议问题