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

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

问题描述

我正在寻找一种工具,可以基于以下几个信号来估算MongoDB索引的大小:

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:


  • 我的收藏中有多少文件

  • 索引字段的大小

  • 如果不是我正在使用的_id的大小ObjectId

  • Geo / Non-geo

  • How many documents in my collection
  • The size of the indexed field(s)
  • The size of the _id I'm using if not ObjectId
  • Geo/Non-geo

有没有人偶然发现过这样的事情?我可以想象,一旦它遇到内存墙并且文档开始被分页到磁盘,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-Trees和索引实现的一些假设我确信它可能足够合理有用。

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字节开销+索引字段的平均大小+转换软糖因子的5个左右字节)]

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来自t在最糟糕的情况下,b-tree数据结构大约是半满的(但是已经分配了一个完整树需要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天全站免登陆