Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I know my document's size inside MongoDB with the ruby driver

Tags:

ruby

mongodb

The limitation of one document in MongoDB is 4Mo. I have some documents really heavy with a lot of data.

How I know my document's size inside MongoDB with the ruby driver ?

like image 770
shingara Avatar asked Mar 28 '10 12:03

shingara


People also ask

How do I see the size of a file in MongoDB?

To get the exact size (in bytes) of the document, stick to the Object. bsonsize() function.

What is the size of an object in MongoDB?

The maximum BSON document size is 16MB or 16777216 bytes. All conversions should use base-2 scale, e.g. 1024 kilobytes = 1 megabyte. If maxCollectionSize is less than or nearly equal to the target collection, increase the chunk size to ensure successful initial sharding.

How big is a 16MB MongoDB document?

With its 16Mb limit, a MongoDB document can easily store around 2 million values of 64-bit numbers (also dates and booleans). But strings are a special case. Each UTF-8 character takes one byte.

What is Max collection size in MongoDB?

Hi Federica, The maximum size an individual document can be in MongoDB is 16MB with a nested depth of 100 levels.


1 Answers

Or native Object.bsonsize(db.Foo.findOne());

like image 80
Zack Bartel Avatar answered Nov 15 '22 22:11

Zack Bartel