If you definitely don't need spherical geometry or multiple fields in a composite geoinformer (see notes in Geospatial Indexes in the MongoDB manual), 2d would be more appropriate. There will also be a slight advantage in storing coordinates as obsolete pairs (longitude, latitude) rather than GeoJSON points. This is probably not enough to significantly affect write performance, but it depends on what you mean by โmany recordsโ and whether they will push your I / O limits.
I'm not sure about the relative query performance for different types of geoinformation, but you can easily set up a representative test case in your own development / deployment environment for comparison. Make sure that you average the measurements over a series of iterations so that the documents are loaded into memory, and there is a fair comparison.
You can also consider the haystack index , which is designed to return results for 2d queries in a small area, combined with additional field criteria (for example, "find restaurants near longitude, latitude"). If you are not concerned about accuracy or sorting by distance (and have an additional search field), this type of index may work well for your use case.
Stennie
source share