I encountered a strange behavior of mongo and I would like to clarify it a bit. I wanted practically find out how many bytes does a single document consume when it has only one boolean attribute present in.
Using Stackoverflow, I found out that I can use the following command
Object.bsonsize - some javascript method that should return a size in bytes
While Executing these commands I got some results which is confusing.
Here I provide with the steps I incorporated
I Created a Database called mydatabase and stored a collection called datarandom which has one attribute called status and I have set it as false.It was assigned an Object Id=558bf45d5ea9019aec35d7a2. I ran the following query in RoboMongo
Object.bsonsize(db.datarandom.find( {"_id" :ObjectId("558bf45d5ea9019aec35d7a2")}));
I got 100 bytes.
I Ran the second Query on RoboMongo Which is as follows
Object.bsonsize(db.datarandom.findOne( {"_id" :ObjectId("558bf45d5ea9019aec35d7a2")}));
I got the output as 31 bytes only!!!!!!
Can Somebody Explain why I am getting two different outputs when I use Find and FindOne when there is only one Document in my Collection with only boolean as an attribute.