I would like to find source to understand BSON-Format

21 views
Skip to first unread message

Mani Challa

unread,
Mar 4, 2018, 4:11:58 PM3/4/18
to mongodb-user

Hi All,


Earlier I've done MongoDB DBAs course, I understood BSON-Format and I'm assuming for nested JSON documents also the BSON-Format will be the linear (is it going to maintain any new node to hold nested documents, which will get link with parent-doc ?).

The doubt I've is mongoDB supports dynamic schema, how mongoDB engines is going to manages millions of old documents after adding few more new fields to that collection.


Thanks in advance.

Regards, Manikanta Challa.

Kevin Adistambha

unread,
Mar 8, 2018, 11:14:27 PM3/8/18
to mongodb-user

Hi Manikanta

MongoDB stores documents as-is, with no special recognition of individual field in the document. MongoDB considers a document as a single whole unit, so it doesn’t really matter what it contains (to some extent). This is different than the typical tabular database, where each table must be predefined, and each column must be known before a single row can be written to it.

Where the fields became important is when you create an index. If you create an index, say db.collection.createIndex({a:1}), MongoDB will scan each document in the collection looking for any document with the field a. It will insert a pointer to that document in the index, and record that document’s value of a. If a document doesn’t have the field a, it will record it as null. This would be slightly different for sparse or partial index, but the process is generally the same.

If you have more specific question, please provide some sample documents.

Best regards
Kevin

Reply all
Reply to author
Forward
0 new messages