mongodb - 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 个索引是否有意义,或者有一种有效的方法将这些索引组合到较少数量的索引下?
解决方案
创建三个索引,每个字段一个。Mongo 能够组合多个索引,请参阅索引交集
验证性能并查看执行计划(使用explain()
)
推荐阅读
- networking - K8s 是否在普通的 Layer2 网络基础设施上运行?
- c# - 压缩后无效的 C# Zip 文件
- javascript - 我如何让每个人都有不同的频道(实时聊天应用程序)
- python - Telegram Telethon:如果您知道频道哈希,如何获取消息
- javascript - multiple conditions to Show input field only if a specific option is selected
- python - Python - 寻求获得布尔值排列的完整列表
- java - 将带有子项目的 Maven 项目导出到 jar 文件
- javascript - 使用节点 js express js 获取用户的密码返回未定义
- java - 如何删除我的 SQliteOpenhelper 上的项目
- azure-synapse - 删除 Azure Synapse 数据库的数据库错误