MySQL indexes - how many are enough?

前端 未结 6 1931
悲&欢浪女
悲&欢浪女 2020-12-09 17:56

I\'m trying to fine-tune my MySQL server so I check my settings, analyzing slow-query log, and simplify my queries if possible.

Sometimes it is enough if I am indexi

6条回答
  •  难免孤独
    2020-12-09 18:46

    As a general rule, you should have indexes on all primary keys (you don't have a choice in that), all foreign keys, and any other fields you commonly use to fetch rows.

    For example, if I commonly look up users by username, I would have that indexed, even if user ID was the primary key.

提交回复
热议问题