Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
223 views
in Technique[技术] by (71.8m points)

database - Mongodb 16 MB document example, how much actual data?

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

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

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...