Reputation: 6406
I am scratching my head around from past two days to get it right. I have a live data set of around 20M lat, long and address. Now, I want to store them in MongoDB such that query to find the address for a given lat, long is fast. Some of the solutions that I found on MongoDB are :
but how good is find query for an exact match of lat, long?
Upvotes: 0
Views: 804
Reputation: 313
MongoDB uses a GeoHash and a B-tree internally for its 2dsphere
indices, which provides very fast area lookups using $near
and $geoNear
; you can use $minDistance
and $maxDistance
of 0 for exact matches but you may want to use a $maxDistance
of 1 if you're worried about issues relating to floating point precision. In many cases it can be important to limit(1)
your results if they are densely distributed in some places, although for street addresses that should not be an issue. On my dev machine I can query a collection with 40 million polygons, totalling nearly 50GB of data, in 300-400 ms.
Upvotes: 1