What is the cost of indexing multiple db columns?

后端 未结 7 1435
孤街浪徒
孤街浪徒 2020-12-19 07:02

I\'m writing an app with a MySQL table that indexes 3 columns. I\'m concerned that after the table reaches a significant amount of records, the time to save a new record wi

7条回答
  •  一个人的身影
    2020-12-19 07:51

    I made some simple tests using my real project and real MySql database.

    My results are: adding average index (1-3 columns in an index) to a table - makes inserts slower by 2.1%. So, if you add 20 indexes, your inserts will be slower by 40-50%. But your selects will be 10-100 times faster.

    So is it ok to add many indexes? - It depends :) I gave you my results - You decide!

提交回复
热议问题