mongdb位置索引

一:接上一篇3

1.长方形范围内得点

2.圆中的点

3.多边形的点

二:

1.geoNear查询 使用runCommand命令

db.runCommand(

{geoNear:<collection>m

near:[x,y],

minDistance:

maxDistance:

num:(返回的数目)

})

nscanned:扫描到哪些数据

time:花费的时间

avgDistance:平均距离

2。2Dsphere索引

db.collection.ensureIndex({w:"2dsphere"})

GeoJSON:描述一个点,一条直线,多边形等形状‘

格式:

{type:" ",coordinates:[<coordinates>]}

与2d索引查询类似。支持$minDistance #maxDistance

查询交叉点

三:索引构建情况分析

好处:加快索引相关查询

坏处:增加磁盘消耗,降低写入性能

如何评判当前索引构建情况:

1.mongostat工具

2.profile集合

3.日志

4.explain分析

原文地址:https://www.cnblogs.com/lilight/p/7502028.html