From: Bruno Wolff III <bruno@wolff.to>
To: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Cc: Virgile Beddok <virgile.beddok@igd.fraunhofer.de>
Cc: pgsql-novice@postgresql.org
Cc: pgsql-advocacy@postgresql.org
Cc: pgsql-admin@postgresql.org
Subject: Re: [pgsql-advocacy] Function which gives back the nearest neighbours
Date: Sun, 27 Mar 2005 10:36:53 -0600
Message-ID: <20050327163653.GH9280@wolff.to> (raw)
In-Reply-To: <42464392.9040903@familyhealth.com.au>
References: <2657.146.140.8.144.1111775776.squirrel@webmail.igd.fraunhofer.de>
<42464392.9040903@familyhealth.com.au>
On Sun, Mar 27, 2005 at 13:24:34 +0800,
Christopher Kings-Lynne <chriskl@familyhealth.com.au> wrote:
> >I'm looking for an existing function which allows me to search the nearest
> >neighbours of the requested value.
>
> Well you could try something like:
>
> SELECT * FROM table ORDER BY ABS(val - 2) LIMIT 1;
>
> That doesn't get you all the way there, but it's an idea...
For multidimensional objects you can do the same thing with a distance
metric function. It will be relatively slow since this won't be indexable
and will require a sort of all of the values. If you have some bound on
how far apart points can be, then you might be able to limit the set
of candidate points using an indexable search.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: bruno@wolff.to, chriskl@familyhealth.com.au, virgile.beddok@igd.fraunhofer.de, pgsql-novice@postgresql.org, pgsql-advocacy@postgresql.org
Subject: Re: [pgsql-advocacy] Function which gives back the nearest neighbours
In-Reply-To: <20050327163653.GH9280@wolff.to>
References: <2657.146.140.8.144.1111775776.squirrel@webmail.igd.fraunhofer.de> <42464392.9040903@familyhealth.com.au> <20050327163653.GH9280@wolff.to>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox