我需要一些关于如何正确设置 w/mongodb 索引的建议。
假设我的数据收集是这样的:
球员
- age
- scores
- fouls
- yellow cards
- red cards
- offsides
我的问题是我的潜在查询可以涵盖所有索引组合,例如:
Get players that age < 30 and yellow card > 3
Get players that age < 30 and yellow card > 3 and red_cards >6
Get players that age < 30 and red_cards card > 3 and scores > 2
Get players that scores < 30 and yellow card > 3 and fouls < 6 and red_cards >2
Get players that scores < 30 and yellow card > 3 and fouls < 6 and red_cards >2 and age > 25
在这种情况下分配我的索引的最佳方法是什么?如果我的集合有 6 个字段,就像我的示例中一样,我需要 36 个索引吗?或者每个索引有一个字段会是更好的选择吗?