Mongodb - 仅对二级集合建立索引 [英] Mongodb - Indexing on secondary collections only

查看:315
本文介绍了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?

例如。我有Product-Category的产品系列作为字段。我不希望在主数据库上索引此字段,我只想在副本设置辅助设备上索引,因为我将仅从辅助设备读取数据。

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).

I发现了两件事:


  1. 这对我来说就像是一个黑客,但有些人建议使用配置为永远不会成为主要的,他们暂时将其从副本集中取出,添加其他索引,然后将其添加回副本集 - 不同的索引在不同的副本集成员上

并且该stackoverflow发布还引用了以下打开的MongoDB增强请求允许不同复制集上的索引p = 0节点 https://jira.mongodb.org/browse/ SERVER-3664 。请投票!

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天全站免登陆