2dsphere vs 2d index:哪个"更好"/更快?

 nancy 发布于 2023-02-04 15:33

Ι有一个数据库只有我的文件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

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

但是,因为我的所有文档都是积分,所以我可以在我的架构中有一个选项,但没有太大区别.

对于2dsphere:

location : { 
      type : "Point" ,
      coordinates : [10,45] 
}

或2d指数:

location : [10,45]

我的问题归结为哪一个更快?我真的不知道如何测量它.

这个问题假设我只想查询一个box数据的平方而不关心复杂的多边形搜索:使用$ box只支持2d索引(如果我正确读取)或者使用$ polygon方法$ geoWithi n两个索引都支持.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有