UUID performance in MySQL?

前端 未结 9 1454
猫巷女王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:50

    Instead of centrally generating unique keys for each insertion, how about allocating blocks of keys to individual servers? When they run out of keys, they can request a new block. Then you solve the problem of overhead by connecting for each insert.

    Keyserver maintains next available id

    • Server 1 requests id block.
    • Keyserver returns (1,1000)
      Server 1 can insert a 1000 records until it needs to request a new block
    • Server 2 requests index block.
    • Keyserver returns (1001,2000)
    • etc...

    You could come up with a more sophisticated version where a server could request the number of needed keys, or return unused blocks to the keyserver, which would then of course need to maintain a map of used/unused blocks.

提交回复
热议问题