digitalbazaar / bedrock-ledger-storage-mongodb

A storage subsystem for Bedrock ledger.
Other
5 stars 3 forks source link

Calculating MongoDB max document size #47

Closed mattcollier closed 5 years ago

mattcollier commented 5 years ago

Adding this information here so this issue can be referenced in code.

The MongoDB driver has to account for some data structure overhead when calculating the maximum document size, namely the size in bytes of the array indexes.

https://github.com/mongodb/node-mongodb-native/commit/436cb84f06c1d71eac82eed2b0f1a301a9ab9b13

https://jira.mongodb.org/browse/NODE-1778

https://github.com/mongodb/node-mongodb-native/blob/436cb84f06c1d71eac82eed2b0f1a301a9ab9b13/lib/bulk/ordered.js#L26

https://github.com/mongodb-js/bson-ext

https://github.com/mongodb/js-bson#calculateObjectSize

Max Size Formula https://github.com/mongodb/node-mongodb-native/blob/436cb84f06c1d71eac82eed2b0f1a301a9ab9b13/lib/bulk/common.js#L700

mattcollier commented 5 years ago

This is for historical reference.