Using more than one index per table is dangerous?

后端 未结 9 2019
春和景丽
春和景丽 2021-02-02 14:25

In a former company I worked at, the rule of thumb was that a table should have no more than one index (allowing the odd exception, and certain parent-tables holding references

9条回答
  •  感情败类
    2021-02-02 14:57

    Yes, definitely - too many indexes on a table can be worse than no indexes at all. However, I don't think there's any good in having the "at most one index per table" rule.

    For SQL Server, my rule is:

    • index any foreign key fields - this helps JOINs and is beneficial to other queries, too
    • index any other fields when it makes sense, e.g. when lots of intensive queries can benefit from it

    Finding the right mix of indices - weighing the pros of speeding up queries vs. the cons of additional overhead on INSERT, UPDATE, DELETE - is not an exact science - it's more about know-how, experience, measuring, measuring, and measuring again.

    Any fixed rule is bound to be more contraproductive than anything else.....

    The best content on indexing comes from Kimberly Tripp - the Queen of Indexing - see her blog posts here.

提交回复
热议问题