Re: "People near me" query - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: "People near me" query
Date
Msg-id 20040319173728.GA31777@wolff.to
Whole thread Raw
In response to "People near me" query  (David Garamond <lists@zara.6.isreserved.com>)
Responses Re: "People near me" query
List pgsql-general
On Fri, Mar 19, 2004 at 17:05:11 +0700,
  David Garamond <lists@zara.6.isreserved.com> wrote:
> Imagine an Orkut-like site. Suppose we have 'person' table of 100k
> people. About 75% of these people fill in their location
> (City/State/Country) information. We also have a 'city' table containing
> list of cities with their state & country and each city's
> latitude/longitude. Assume all people's location is registered in the
> 'city' table.
>
> How does one design a database to be able to process "Show me people
> that live no farther than 250 miles from where I live" quickly? I can do
> "Show me people that live within (A-X to A+X) latitude and (B-X to B+X)
> longitude" though. (Where A and B is the latitude and longitude [of the
> person], and X is some numeric value.

The earthdistance contrib package allows you to do these kinds of queries
with gist indexes. This might be a simpler solution than using PostGIS
which has a lot of other features you don't appear to be using.

pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: unsigned types, binary op. and cast pb
Next
From: Max Ahston
Date:
Subject: Q: How do I return differnt rows depending on values in a PL/pgSQL function?