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

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: [pgsql-advocacy] Function which gives back the nearest neighbours
Дата
Msg-id 20050327163653.GH9280@wolff.to
обсуждение исходный текст
Ответ на Re: [pgsql-advocacy] Function which gives back the nearest neighbours  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
Ответы Re: [NOVICE] [pgsql-advocacy] Function which gives back the nearest neighbours  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-admin
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.

В списке pgsql-admin по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Import Database
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Help: my table is corrupt!