我的收藏中有这样的文档结构:
{
"deviceId" : "9113",
"data" : {
"qIdx" : 106
"points" : [
{ "eDate" : "2013-06-10T00:00:13.000Z" } ,
{ "eDate" : "2013-06-10T00:00:14.000Z" }
]
} ,
"rdate" : { "$date" : "2013-05-30T22:25:04.359Z"} ,
"_id" : { "$oid" : "51a7d1c0debcab563502cc41" }
}
我有索引:
{deviceId: 1, data.points.eDate: 1}
当我进行如下查询时:
{
deviceId: "9113",
data.points.eDate: {
$gt: "2013-05-11T00:00:00.000Z",
$lt:"2013-05-12T00:00:00.000Z"
}
}
索引不使用一个界限 - 这是解释:
{
"cursor" : "BtreeCursor deviceId_1_data.points.eDate_1" ,
"nscanned" : 4015 ,
"nscannedObjects" : 4015 ,
"n" : 10 , "millis" : 8297 ,
"nYields" : 103 ,
"nChunkSkips" : 0 ,
"isMultiKey" : true ,
"indexOnly" : false ,
"indexBounds" : {
"deviceId" : [[ "9113" , "9113"]],
"data.points.eDate" : [
[ "2013-05-11T00:00:00.000Z" , { }]
]
}
}
我的 mongodb 版本是 2.0.7