Home > Net >  why the size of json files is larger than the size of its collection in mongodb
why the size of json files is larger than the size of its collection in mongodb

Time:10-22

i have a large number of json files 2M(5Go).I imported to mongodB, I noticed that the total size of my mongoDb has only (0.9Go) which mean mongodb helps me to reduce momery storage. what is the explication behind this?is some kind of compression or just because he store is a json object instead json files ?

CodePudding user response:

MongoDB actually stores objects in the BSON format. Since it is binary-encoded, it is naturally expected to demand less disk space.

CodePudding user response:

BSON is more compact (as mentioned by @amiasato), but not by a lot. You don't have quotes or braces, but you have to specify length for every field. _id field and other binary blobs take 2x less space compared to JSON, but in a typical db, these do not take up the majority of space.

The disk usage savings you're observing are coming from WiredTiger's compression of data files, I'm 99% sure. (WiredTiger is the default storage engine in current version of mongodb)

  • Related