Mongodb _id
字段被定义为:
ObjectId is a 12-byte BSON type, constructed using:
a 4-byte value representing the seconds since the Unix epoch,
a 3-byte machine identifier,
a 2-byte process id, and
a 3-byte counter, starting with a random value.
在PostgreSQL中,最高效的表示该字段的方法是什么?
char(24)
并存储ObjectId的十六进制表示,然后添加CHECK约束以确保它具有正确的格式。至于“有效”的意义是什么?速度?空间?程序员时间?减少人数?我发现24个字符的十六进制表示法是最容易和友好的格式。根据您用于与PostgreSQL接口的内容,您可能无法轻松使用postgresbson。 - mu is too short