MySQL - why not index every field?

前端 未结 6 1966
后悔当初
后悔当初 2020-12-02 07:12

Recently I\'ve learned the wonder of indexes, and performance has improved dramatically. However, with all I\'ve learned, I can\'t seem to find the answer to this question.<

6条回答
  •  时光取名叫无心
    2020-12-02 07:55

    Indexes take up space in memory (RAM); Too many or too large of indexes and the DB is going to have to be swapping them to and from the disk. They also increase insert and delete time (each index must be updated for every piece of data inserted/deleted/updated).

    You don't have infinite memory. Making it so all indexes fit in RAM = good.

    You don't have infinite time. Indexing only the columns you need indexed minimizes the insert/delete/update performance hit.

提交回复
热议问题