How many database indexes is too many?

后端 未结 17 2122
终归单人心
终归单人心 2020-12-07 08:09

I\'m working on a project with a rather large Oracle database (although my question applies equally well to other databases). We have a web interface which allows users to

17条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-07 08:49

    It depends on the operations that occur on the table.

    If there's lots of SELECTs and very few changes, index all you like.... these will (potentially) speed the SELECT statements up.

    If the table is heavily hit by UPDATEs, INSERTs + DELETEs ... these will be very slow with lots of indexes since they all need to be modified each time one of these operations takes place

    Having said that, you can clearly add a lot of pointless indexes to a table that won't do anything. Adding B-Tree indexes to a column with 2 distinct values will be pointless since it doesn't add anything in terms of looking the data up. The more unique the values in a column, the more it will benefit from an index.

提交回复
热议问题