Mysql How do you create a clustered index?

后端 未结 4 616
温柔的废话
温柔的废话 2020-12-05 19:58

I\'m reading all about how clustered indexes work, and think they would be beneficial to my app. I understand that primary keys are automatically clustered indexes, but how

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-05 20:40

    I suggest that you are asking the wrong question.

    One alternative question is "Can I get rid of my current PRIMARY KEY so I can make this other thing 'clustered'?" Often an AUTO_INCREMENT can be eliminated or turned into a simple INDEX.

    The more likely question is "What is the optimal index for this SELECT ...?". Others have pointed out that a second clustered index is out of the question for basic MySQL, so what is the next choice? I can't answer that without knowing the SELECT. However my Index Cookbook answers the question for a large let of SELECTs.

提交回复
热议问题