What are the disadvantages to Indexes in database tables?

前端 未结 2 769
伪装坚强ぢ
伪装坚强ぢ 2021-02-18 22:48

Is there any reason I shouldn\'t create an index for every one of my database tables, as a means of increasing performance? It would seem there must be some reason(s) else all t

2条回答
  •  -上瘾入骨i
    2021-02-18 23:35

    As a minimum I would normally recommend having at least 1 index per table, this would be automatically created on your tables primary key, for example an IDENTITY column. Then foreign keys would normally benefit from an index, this will need to be created manually. Other columns that are frequently included in WHERE clauses should be indexed, especially if they contain lots of unique values. The benefit of indexing columns, such as gender (low-cardinality) when this only has 2 values is debatable. Most of the tables in my databases have between 1 and 4 indexes, depending on the data in the table and how this data is retrieved.

提交回复
热议问题