Has anyone found an efficient way to store BSON ObjectId values in an SQL database?

后端 未结 1 899
粉色の甜心
粉色の甜心 2021-01-21 08:46

We are migrating some data from MySQL to Mongo and have been adding extra fields to some of our DB tables for the ObjectId value of the migrated data objects.

At the mo

相关标签:
1条回答
  • 2021-01-21 09:07

    The range of a 12-byte unsigned int would be 0..79228162514264337593543950335 (29 digits max); according to docs (same URL you cited), a DECIMAL/NUMERIC column packs each group of nine base10 digits into four bytes (adding up to floor(29 / 9) * 4 = 3 * 4 = 12 bytes for the first 27 digits), with the remaining 2 digits taking an additional byte, coming up to 13 bytes of storage for a DECIMAL(29) column.

    Or, you can store them as BINARY(12).

    0 讨论(0)
提交回复
热议问题