I've got a set or lat/longs saved inside a db. I wish to query the db and return documents which are within selection of another lat/lengthy. I understand how to look for the distance between two sets but I'd rather not need to do that for each entry within the db. What's the easiest method to accomplish this?
Possibly you could utilize Geospatial Indexing to do this...
If that is not good, I really built a node.js addon to do nearest neighbor searches known as node-kdtree. It may be used to obtain the nearest n points, and it is fairly quick since it's really a wrapper for an underlying C library. However it seems like it might be an undesirable choice to your requirements because you would need to pull all your data from the DB first to be able to process it. Using the limited information I've, I would recommend that you simply use the built-in functionality of mongodb first.