Re: [pgsql-advocacy] Function which gives back the nearest neighbours - Mailing list pgsql-novice

From Bruno Wolff III
Subject Re: [pgsql-advocacy] Function which gives back the nearest neighbours
Date
Msg-id 20050328172223.GA11567@wolff.to
Whole thread Raw
In response to Re: [pgsql-advocacy] Function which gives back the nearest neighbours  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
Responses Re: [pgsql-advocacy] Function which gives back the nearest  (Joe Conway <mail@joeconway.com>)
List pgsql-novice
On Mon, Mar 28, 2005 at 18:32:09 +0200,
  Virgile Beddok <virgile.beddok@igd.fraunhofer.de> wrote:
>
> I just want to know if there is an existing and implemented function, or
> tree, in Postgres which allows me to directly perform a "nearest neighbour
> search" on multidimensional vectors.

How are you measuring distance? (i.e. Euclidean distance isn't the only
metric that you could be using.)

Earthdistance has functions for doing this using geodesics on the surface
of a sphere.

For 2D, I think there is a function on "point"s that uses Euclidean
distance.

I don't think this is the hard part of your problem. It is easy to create
a metric function and get the point corresponding to the minimal value
using a sort. Being able to limit the sets of points looked at is the
hard part.

pgsql-novice by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: [pgsql-advocacy] Function which gives back the nearest neighbours
Next
From: Joe Conway
Date:
Subject: Re: [pgsql-advocacy] Function which gives back the nearest