From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | bas(at)scheffers(dot)net |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: "People near me" query |
Date: | 2004-03-19 15:01:57 |
Message-ID: | 24093.1079708517@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Bas Scheffers" <bas(at)scheffers(dot)net> writes:
> Once you have that, the rest is easy. create a column of the type "point"
> and store the grid coordinates in there. The just use the "contains"
> operator (~) in a query.
> (http://www.postgresql.org/docs/7.4/static/functions-geometry.html)
> Example:
> My coordinates are 523857,175349. So to find anyone living within 10KM of
> me, I just do "select * from people where '((523857,175349),10000)' ~
> location"
> Unfortunately, Postgres doesn't know how to index this.
You can index such queries using rtree indexes. There was a discussion
of this with a full example just a couple weeks ago:
http://archives.postgresql.org/pgsql-novice/2004-03/msg00070.php
It's likely that PostGIS provides an even better solution, but I haven't
used it.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Carmen Gloria Sepulveda Dedes | 2004-03-19 15:13:12 | 7.4.2 on Solaris 9 - Error |
Previous Message | Stephan Szabo | 2004-03-19 15:00:59 | Re: self referenced table ? |