不知怎的,投影会让我的查询变慢。
这是我的疑问:
{
"$and": [{
"$or": [{
"tiles": "18-137068-57860"
}, {
"tiles": "18-137068-57861"
}, {
"tiles": "18-137068-57862"
}, {
"tiles": "18-137068-57863"
}, {
"tiles": "18-137068-57864"
}, {
"tiles": "18-137068-57865"
}, {
"tiles": "18-137068-57866"
}, {
"tiles": "18-137069-57860"
}, {
"tiles": "18-137069-57861"
}, {
"tiles": "18-137069-57862"
}, {
"tiles": "18-137069-57863"
}, {
"tiles": "18-137069-57864"
}, {
"tiles": "18-137069-57865"
}, {
"tiles": "18-137069-57866"
}, {
"tiles": "18-137070-57860"
}, {
"tiles": "18-137070-57861"
}, {
"tiles": "18-137070-57862"
}, {
"tiles": "18-137070-57863"
}, {
"tiles": "18-137070-57864"
}, {
"tiles": "18-137070-57865"
}, {
"tiles": "18-137070-57866"
}, {
"tiles": "18-137071-57860"
}, {
"tiles": "18-137071-57861"
}, {
"tiles": "18-137071-57862"
}, {
"tiles": "18-137071-57863"
}, {
"tiles": "18-137071-57864"
}, {
"tiles": "18-137071-57865"
}, {
"tiles": "18-137071-57866"
}, {
"tiles": "18-137072-57860"
}, {
"tiles": "18-137072-57861"
}, {
"tiles": "18-137072-57862"
}, {
"tiles": "18-137072-57863"
}, {
"tiles": "18-137072-57864"
}, {
"tiles": "18-137072-57865"
}, {
"tiles": "18-137072-57866"
}, {
"tiles": "18-137073-57860"
}, {
"tiles": "18-137073-57861"
}, {
"tiles": "18-137073-57862"
}, {
"tiles": "18-137073-57863"
}, {
"tiles": "18-137073-57864"
}, {
"tiles": "18-137073-57865"
}, {
"tiles": "18-137073-57866"
}, {
"tiles": "18-137074-57860"
}, {
"tiles": "18-137074-57861"
}, {
"tiles": "18-137074-57862"
}, {
"tiles": "18-137074-57863"
}, {
"tiles": "18-137074-57864"
}, {
"tiles": "18-137074-57865"
}, {
"tiles": "18-137074-57866"
}]
}, {
"lastupdate": {
"$gte": 0
}
}]
}
这是我的预测:
{
"_id": 1,
"_owner": 1,
"destination": 1,
"endtime": 1,
"position": 1,
"speed": 1,
"starttime": 1,
"angle": 1,
"mapspeed": 1,
"vehicleClass": 1,
"target": 1,
"lastupdate": 1,
"createdate": 1,
"hp": 1,
"lastshot": 1,
"geobinding": 1
}
使用投影查询运行6秒,没有77毫秒
我正在运行mongodb 3.0.3
编辑: 似乎“_id”:投影中的1减慢速度,当我删除它时,它很好,但为什么呢?