Reputation: 6242
First I will discuss my use case:
I want to get a point. With this point I want to find the nearest points to roughly the nearest 100 meters. This does not have to be very accurate and not all points need to be the exactly within the 100 meters (ex, 110 meters would be okay or 90 meters would be okay). My main concern is on performance.
I am looking at $box (now called GeoJSON I believe) vs $near. Both seem to fulfill my needs, but which is faster for my use case? The $near command to me seems like it would be faster because with GeoJSOn I need to draw the same box every request then search, but on the other hand from what I read about geopolitical queries is that box shapes are faster to search than proximity.
There is also the haystack index which seems to be great for what I want, but according to this site I can't use it from my http server:
http://blog.mongolab.com/2014/08/a-primer-on-geospatial-data-and-mongodb/
This index is optimized for searches over small areas and is only usable through the geoSearch database command. We don’t discuss haystacking in this blog, but you can read more about it here.
What would be a good performing choice then for this use case?
Upvotes: 0
Views: 64
Reputation: 20699
In general a box
-search should be performing better, because in $near
-lookup the square root (see the pythagorean theorem) should be calculated en mass, which is less efficient
Upvotes: 1