title: Database / geolocation. Finding people nearby
body: <p>I am currently trying to create a small web app that will find other people nearby who are using it as well.</p>
  
  <p>When I use the geolocation feature, I save the "Last known location" of the user on the server for about an hour, after which I remove the location from the database collection (I use MongoDb)</p>
  
  <p>Every time, I compare the position with all the people who have recently checked-in (those in the location collection), to find people who are close.</p>
  
  <p>This method doesn't seem efficient though, the number of people could be huge, which would mean iterating a long list and comparing positions with people who are in different countries.</p>
  
  <p>I'm thinking about dividing into multiple tables for each country or timezone. Which would prevent the app from searching too far.</p>
  
  <p>Any advice or thoughts ?</p>
  
  <p>Thanks</p>