search

Home  >  Q&A  >  body text

mysql - 如何对海量设备ID编号?

有一批海量的设备ID,都是MD5的32字节的字符串,想用Bitmap索引来保存每个设备的某个状态(0或1),但需要把设备ID一一映射到bitmap对象的每一位上,其实就是要把对设备进行整型数字的编码。
开始想用mysql表的自增列来实现,先查询,没有就插入,再取自增的ID,但这样在高并发的情况下,mysql单点可能支撑不住,不知道有没有其它好的办法可以实现设备ID到Integer的映射。

天蓬老师天蓬老师2767 days ago452

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-04-17 13:33:02

    Use GUID. When you need an id but don't need to specify its type or what the id means, but just need different values, GUID is your best choice. Moreover, there is a local expression method of GUID on every platform, so you don’t have to worry about the data being unreadable.

    But then again, why does it have to be int? If this is just your inner OCD, you might as well just use the device's own 32-byte string. Anyway, if you add indexes to the database, it will be the same.

    reply
    0
  • Cancelreply