Re: find close (duplicate) points + create index

Bruno Wolff III <bruno@wolff.to>

From: Bruno Wolff III <bruno@wolff.to>
To: Elinor Medezinski <elinor@bellatrix.tau.ac.il>
Cc: pgsql-novice@postgresql.org, elinor@wise1.tau.ac.il
Date: 2004-03-10T04:16:24Z
Lists: pgsql-novice
On Thu, Mar 04, 2004 at 12:42:23 +0200,
  Elinor Medezinski <elinor@bellatrix.tau.ac.il> wrote:
> Hello,
> 
> I have a table with one column --
> "CREATE TABLE pointtable (point POINT)".
> I'm trying to find duplicate entries, where two entries are considered 
> duplicates if  they're within a radius of 1, meaning something like ~ "select 
> point from pointtable where distance between points <=1".
> Obviously this is not SQL syntax. Is there a way to do this - search within a 
> column itself?

Yes, you can join a table to itself and return records matching some
critera. This isn't going to be fast. I didn't see a distance between
two points function, but it is probably there somewhere. If not you
can check if one point is contained in a circle of radius 1 centered
at the other point. This is something that could use an index, though
it probably wouldn't help when checking the whole table. It probably
would speed up checking a single point for conflicts.