UUID performance in MySQL?

前端 未结 9 1487
猫巷女王i
猫巷女王i 2020-11-27 10:14

We\'re considering using UUID values as primary keys for our MySQL database. The data being inserted is generated from dozens, hundreds, or even thousands of remote computer

9条回答
  •  不知归路
    2020-11-27 10:52

    A UUID is a Universally Unique ID. It's the universally part that you should be considering here.

    Do you really need the IDs to be universally unique? If so, then UUIDs may be your only choice.

    I would strongly suggest that if you do use UUIDs, you store them as a number and not as a string. If you have 50M+ records, then the saving in storage space will improve your performance (although I couldn't say by how much).

    If your IDs do not need to be universally unique, then I don't think that you can do much better then just using auto_increment, which guarantees that IDs will be unique within a table (since the value will increment each time)

提交回复
热议问题