mongodb 2d索引精度如何影响查询性能?

时间:2019-07-14 15:55:26

标签: mongodb indexing geospatial nearsphere

我正在使用此查询来获取接近给定位置的对象(按距离排序):

{
    "id": { // String
        "$nin": ["<vals>"]
    },
    "date": { // Date
        "$gte": "<val>"
    },
    "location": { // Legacy coordinate pairs
        "$nearSphere": ["<val>"],
        "$maxDistance": "<val>"
    },
    "count": { // Integer
        "$gt": "<val>"
    },
    "param1": { // String
        "$in": ["<vals>"] // 1-10 values
    },
    "param2": { // String
        "$in": ["<vals>"] // 1-10 values
    },
    "param3": { // String
        "$in": ["<vals>"] // 10-100 values
    }
}

我尝试了该索引,但查询执行速度很慢(200毫秒):

{
    "location": "2dsphere",
    "count": 1,
    "date": -1,
    "param1": 1
}

结果的位置精度应为〜+/- 100m或0.001十进制度。该位置存储为旧版坐标对。

具有较低/较高precision的2d索引会提高性能吗?

0 个答案:

没有答案