Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Does anyone have a practical downloadable/viewable example of a 16mb (max size) mongodb doucument?

Should be alot of data but im trying to get the feel and understanding how much data can you store in a 16 mb document, like "How many sql rows of a 10 column table would that be" sort of question

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
221 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can calculate the size of various documents using the BSON spec.

For example, a document {a:1} consisting of one key with an integer value would take 5+1+2+4=12 bytes.

You can use various drivers to convert your data to BSON to see how much space it actually takes up:

serene% irb -rbson
irb(main):001:0> {a:1}.to_bson.to_s
=> "fx00x00x00x10ax00x01x00x00x00x00"
irb(main):002:0> {a:1}.to_bson.to_s.length
=> 12

If you have, let's say, documents which are flat (non-nested) mappings with keys that are 10 bytes long and 64-bit integer values, each key-value pair takes up 1+10+1+8=20 bytes. You can have about 800,000 such key-value pairs in a single document.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...