Jump to content

Find other users near current user


RogerZF

Recommended Posts

I want to be able to find how close my users are to eachother.

I have a HUGE list (thousands) of IP addresses in a MySQL database. I can match IP's with longitudes/latitudes. My problem is finding other users close to the current logged in user. Do I need to match longitude/latitude for EVERY IP and calculate distance? Wouldn't that KILL the server AND the SQL server?

What's the most efficient way of doing this? I know Myspace has a "find users close to you" feature, but I can't figure out how they made theirs. Also, I don't think zip code is much of an option as not every country has a zip code. I have TONS of international visitors (USA, Europe, Australia, Canada, UAE, etc.). Do all those countries have zip codes? I can't think of an efficient way of doing this without killing the server.
Link to comment
Share on other sites

Nearly every country has a zip code.. so that's an option.

You could use a strategy like this

- Match all longitudes and latitudes near the location of interest
- Find all IPs which match those longitude/latitude combinations
- Find all IPs from those which are in your database

Seems a bit expensive.  But you can cache the results at various stages in your algorithm, meaning only the first request will have performance hit.

Another option could be to store an 'IP block adjacency' look up table.  Then you can lookup immediately which IP blocks are adjacent to your IP block of interest.  It'll take a while to generate and it'll be big, but it'll be fast..
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.