首页 > 解决方案 > MongoDB 副本集集群中的索引

问题描述

在 myreplica set mongodb cluster中,read可能会发生查询:

- either on column1
- or on column2
- or on combination of column1 and column2
- or on combination of column1 and column3
- or on combination of column2 and column3
- or on combination of column1 and column2 and column3

为上述每个案例创建 6 个索引是否有意义,或者有一种有效的方法将这些索引组合到较少数量的索引下?

标签: mongodbmongodb-queryreplicaset

解决方案


创建三个索引,每个字段一个。Mongo 能够组合多个索引,请参阅索引交集

验证性能并查看执行计划(使用explain()


推荐阅读