在Mongodb中,如何仅在辅助节点(副本集)中的集合中的字段上建立索引 [英] In Mongodb, How can I Index on field(s) in collection(s) in secondary node(replica-set) only

查看:68
本文介绍了在Mongodb中,如何仅在辅助节点(副本集)中的集合中的字段上建立索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以仅在我不需要在主副本集上的索引时选择性地在辅助副本集集合字段上建立索引吗?

Is there any way to selectively index on secondary replica-set collection fields only as I don't need those index on primary's collection?

例如.我将产品类别"作为产品集合.我不想在主数据库上为该字段建立索引,我只希望在副本集辅助数据库上建立索引,因为我将仅从辅助数据库读取数据.

Eg. I have Product collection with Product-Category as field. I don't want to index this field on primary, I only want index on replica-set secondary as I will be reading data only from secondary.

推荐答案

我意识到这是一个老话题,但是最近我正在探讨同一主题.我想针对实时数据运行数据报告工具,并且我想为此使用不同的索引,但是我不想以影响服务应用程序请求的主节点性能的方式引入它们(因为更多的索引会增加内存消耗,并且我相信这会以某种方式影响写入性能,这取决于所选择的MongoDB Write Concern对使用方的应用程序是可见的.)

I realize this is an old thread, but I was recently digging around on the same topic. I want to run data reporting tools against my live data, and I assume I'll want different indexes for that, and but I don't want to introduce them in a way that impacts the performance of my primary nodes that are serving application requests (since more indexes increase memory consumption and I believe can impact write performance in a way that would be visible to the consuming application depending on the chosen MongoDB Write Concern).

我遇到了两件事:

  1. 对我来说,这很像黑客,但有些人建议使用配置为从不成为主数据库的隐藏辅助数据库,他们暂时将其从副本集中删除,添加其他索引,然后添加它回到副本集-不同副本集成员上的不同索引

并且该stackoverflow发布还引用了以下打开的MongoDB增强请求允许在副本集p = 0节点上使用不同的索引"

And that stackoverflow posting also referenced the following open MongoDB enhancement request "Allow different indexes on replica set p=0 nodes" https://jira.mongodb.org/browse/SERVER-3664. Please vote it up!

Pete

这篇关于在Mongodb中,如何仅在辅助节点(副本集)中的集合中的字段上建立索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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