MySQL – why not index every field?

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.

Leave a Comment