Mongodb 16 MB文件示例,实际数据是多少? [英] Mongodb 16 MB document example, how much actual data?

查看:43
本文介绍了Mongodb 16 MB文件示例,实际数据是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人有一个16mb(最大大小)mongodb伪装的实用的可下载/可见示例吗?

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

应该有很多数据,但我想尽力而为,并理解您可以在16 mb的文档中存储多少数据,就像"10列表中有多少条sql行会是这种问题"

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

谢谢

推荐答案

您可以使用 BSON规范.

例如,由一个具有整数值的键组成的文档 {a:1} 将占用5 + 1 + 2 + 4 = 12个字节.

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

您可以使用各种驱动程序将数据转换为BSON,以查看其实际占用的空间:

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
=> "\f\x00\x00\x00\x10a\x00\x01\x00\x00\x00\x00"
irb(main):002:0> {a:1}.to_bson.to_s.length
=> 12

如果您有扁平(非嵌套)映射的文档,这些文档的键长为10个字节,且键值为64位整数,则每个键值对占用1 + 10 + 1 + 8 = 20个字节.一个文档中可以有大约80万个这样的键值对.

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.

这篇关于Mongodb 16 MB文件示例,实际数据是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆