I am working on an application where I need to make analysis that what will be the storage size of BSON structure if same data is stored which is stored in MySQL. Basically I am comparing MongoDB and MySQL storage. Is there any relation between them? or some formula which gives size of BSON storage?

1 Answer 1


In each database, there is no one answer to what size something is when it is stored. In MongoDB there are several factors to take into account, for example:

  • What types are being stored (BSON having more types than JSON, and with each getting different allocations)
  • Should you include the (16 byte) record header?
  • Is the collection you are storing the data in using powerOf2Sizes?
  • Are you using the default storage engine? (pluggable engines were just announced at MongoDB World 2014 and Toku has provided a fork with very different storage characteristics for some time)
  • Do you need to include index size in the storage calculation?
  • Does running a compact/repair alter the storage characteristics?

That note about storage engines is a good one. I am not a MySQL expert, but I know there are multiple options there (MyISAM, ARCHIVE, MERGE and others) that will again have very different storage characteristics just within MySQL itself.

There's no easy answer on this one I'm afraid - you are going to have to tightly control the data being stored, look for equivalent/fair types across the two databases to store. Then you will need to familiarize yourself with the intricacies of each in terms of how to measure storage and how different actions might impact that storage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.