simo
simo

Reputation: 41

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

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 ?

Upvotes: 1

Views: 1177

Answers (2)

Sergio Tulentsev
Sergio Tulentsev

Reputation: 230296

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)

Upvotes: 2

amiasato
amiasato

Reputation: 1020

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

Upvotes: 2

Related Questions