我正在努力理解如何更好地构建Mongo查询的索引,因为我看到一些长时间运行的查询。
目前我看到的查询大致如下:
"cursor" : "BtreeCursor modTime_-1_color_1 multi",
"isMultiKey" : false,
"n" : 0,
"nscannedObjects" : 0,
"nscanned" : 104936,
"nscannedObjectsAllPlans" : 104935,
"nscannedAllPlans" : 314806,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 70,
"nChunkSkips" : 0,
"millis" : 14237,
"indexBounds" : {
"modTime" : [
[
{
"$maxElement" : 1
},
{
"sec" : 1360267645,
"usec" : 0
}
]
],
"color" : [
[
"Green",
"Green"
],
[
"Blue",
"Blue"
],
[
"Yellow",
"Yellow"
]
]
},
查询语句如下:
{"modTime":{"$gte":{"sec":1360267645,"usec":0}},"color":{"$in":["Green","Blue","Yellow"]}}
是否有其他方法可以创建此索引,以便不会扫描那么多结果?
提前感谢您的想法和建议。