在mongodb中每天生成集合是个好主意吗 [英] Is it a good idea to generate per day collections in mongodb

查看:95
本文介绍了在mongodb中每天生成集合是个好主意吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一天中为数据创建每天的收集是否是一个好主意(我们可以从每天开始,然后在每小时有太多数据的情况下转移到每小时).我们可以在mongodb中创建的集合数量是否受到限制,否则是否会导致性能损失(mongodb维护如此多的集合是否会产生开销).大量馆藏对性能有不利影响吗?

Is it a good idea to create per day collections for data on a given day (we could start with per day and then move to per hour if there is too much data). Is there a limit on the number of collections we can create in mongodb, or does it result in performance loss (is it an overhead for mongodb to maintain so many collections). Does a large number of collections have any adverse effect on performance?

为了给您更多的背景信息,数据将更像是Facebook feed,并且只有最新数据(例如上个星期或一个月)对我们而言更为重要.每天进行收集使文档数量很少,并且可能会导致快速访问.即使我们需要旧数据,我们也可以使用旧数据集.这有意义吗,还是我朝着错误的方向前进?

To give you more context, the data will be more like facebook feeds, and only the latest data (say last one week or month) is more important to us. Making per day collections keeps the number of documents low, and probably would result in fast access. Even if we need old data, we can fall back to older collections. Does this make sense, or am I heading in the wrong direction?

推荐答案

您真正需要的是存档旧数据.我建议您在mongodb邮件列表中查看此线程:
https://groups.google.com/forum/#!topic/mongodb -user/rsjQyF9Y2J4 Michael Dirolf(10gen)的最新帖子说:

what you actually need is to archive the old data. I would suggest you to take a look at this thread at the mongodb mailing list:
https://groups.google.com/forum/#!topic/mongodb-user/rsjQyF9Y2J4 Last post there from Michael Dirolf (10gen)says:

操作系统将处理LRU数据,因此,如果所有查询都 接触应保留在内存中的数据的相同部分 与集合的总大小无关."

"The OS will handle LRUing out data, so if all of your queries are touching the same portion of data that should stay in memory independently of the total size of the collection."

所以我想您可以保留单个集合,并且良好的索引可以完成工作.
无论如何,如果馆藏太大,您可以随时运行手动存档过程.

so I guess you can stay with single collection and good indexes will do the work.
anyhow, if the collection goes too big you can always run manual archive process.

这篇关于在mongodb中每天生成集合是个好主意吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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