是否有任何工具可以估算 MongoDB 中的索引大小? [英] Are there any tools to estimate index size in MongoDB?

查看:17
本文介绍了是否有任何工具可以估算 MongoDB 中的索引大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种工具来根据以下几个信号对 Mo​​ngoDB 索引的大小进行适当的估计:

I'm looking for a tool to get a decent estimate of how large a MongoDB index will be based on a few signals like:

  • 我的收藏中有多少文档
  • 索引字段的大小
  • 如果不是 ObjectId,我使用的 _id 的大小
  • 地理位置/非地理位置

有没有人偶然发现这样的事情?我可以想象,一旦 Mongo 遇到内存墙并且文档开始被分页到磁盘时,它的性能就会下降,我可以想象它会非常有用.如果我有一个正常运行的数据库并且想要添加另一个索引,那么我知道它是否会太大的唯一方法就是实际添加它.

Has anyone stumbled across something like this? I can imagine it would be extremely useful given Mongo's performance degradation once it hits the memory wall and documents start getting paged out to disk. If I have a functioning database and want to add another index, the only way I'll know if it will be too big is to actually add it.

它不需要精确到位,但有一些关于 B 树和索引实现的假设,我相信它可能足够合理以提供帮助.

It wouldn't need to be accurate down to the bit, but with some assumptions about B-Trees and the index implementation I'm sure it could be reasonable enough to be helpful.

如果它不存在,我想构建并开源它,所以如果我错过了此计算所需的任何参数,请包含在您的答案中.

If this doesn't exist already I'd like to build and open source it, so if I've missed any required parameters for this calculation please include in your answer.

推荐答案

我刚刚与一些 10gen 工程师交谈过,但没有工具,但您可以根据以下公式进行包络计算:

I just spoke with some of the 10gen engineers and there isn't a tool but you can do a back of the envelope calculation that is based on this formula:

2 * [ n * ( 18 bytes overhead + avg size of indexed field + 5 or so bytes of conversion fudge factor ) ]

其中 n 是您拥有的文档数量.

Where n is the number of documents you have.

开销和转换填充是 mongo 特定的,但 2x 来自 b 树数据结构,在最坏的情况下大约是半满(但分配了完整树所需的空间的 100%).

The overhead and conversion padding are mongo specific but the 2x comes from the b-tree data structure being roughly half full (but having allocated 100% of the space a full tree would require) in the worst case.

我会解释更多,但目前我正在了解它.此演示文稿将包含更多详细信息:http://www.10gen.com/presentations/mongosp-2011/mongodb-internals

I'd explain more but I'm learning about it myself at the moment. This presentation will have more details: http://www.10gen.com/presentations/mongosp-2011/mongodb-internals

这篇关于是否有任何工具可以估算 MongoDB 中的索引大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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