> db.test.ensureIndex({x: 1, location: '2dsphere'})
{
"createdCollectionAutomatically" : false,
"numIndexesBefore" : 1,
"numIndexesAfter" : 2,
"ok" : 1
}
> db.test.find({x: 0}).explain()
{
"cursor" : "BasicCursor",
"isMultiKey" : false,
"n" : 1,
"nscannedObjects" : 100009,
"nscanned" : 100009,
"nscannedObjectsAllPlans" : 100009,
"nscannedAllPlans" : 100009,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 781,
"nChunkSkips" : 0,
"millis" : 40,
"server" : "hackintosh:27017",
"filterSet" : false
}
MongoDB 版本:2.6.2
x
我在and上创建了一个复合索引location
,但是当我在 上查询时x
,为什么它不起作用?