Dio*_*lor 19 mongodb mongodb-indexes
Ι有一个数据库只有我的文件Points.我考虑添加地理空间索引.所以我可以选择2dhere和2d.
MongoDB.org有:
2dsphere索引支持:
- Calculations on a sphere
- Both GeoJSON objects and legacy coordinate pairs
- A compound index with scalar index fields (i.e. ascending or
descending) as a prefix or suffix of the 2dsphere index field
Run Code Online (Sandbox Code Playgroud)
2d索引支持:
- Calculations using flat geometry
- Legacy coordinate pairs (i.e., geospatial points on a flat
coordinate system)
- A compound index with only one additional field, as a suffix of
the 2d index field
Run Code Online (Sandbox Code Playgroud)
但是,因为我的所有文档都是积分,所以我可以在我的架构中有一个选项,但没有太大区别.
对于2dsphere:
location : {
type : "Point" ,
coordinates : [10,45]
}
Run Code Online (Sandbox Code Playgroud)
或2d指数:
location : [10,45]
Run Code Online (Sandbox Code Playgroud)
我的问题归结为哪一个更快?我真的不知道如何测量它.
这个问题假设我只想查询一个box数据的平方而不关心复杂的多边形搜索:使用$ box只支持2d索引(如果我正确读取)或者使用$ polygon方法$ geoWithi n两个索引都支持.
除了您已经完成的研究之外,我只是想添加我在这两个索引之间遇到的另一个差异。
默认情况下,旧坐标对上的 2d 索引使用 26 位精度,这大致相当于使用默认范围 -180 到 180 的 2 英尺或 60 厘米精度。精度是通过 geohash 值的位大小来衡量的用于存储位置数据。您可以配置精度高达 32 位的地理空间索引。
db.<collection>.ensureIndex( {<location field> : "<index type>"} , { bits : <bit precision> } )
来源: MongoDB 文档参考
| 归档时间: |
|
| 查看次数: |
4567 次 |
| 最近记录: |