Cube extension kNN support

From: Stas Kelvich <stas(dot)kelvich(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Cube extension kNN support
Date: 2013-09-22 23:38:48
Message-ID: 9E07E159-E405-41E2-9889-A04F534FC257@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello, hackers.

Here is the patch that introduces kNN search for cubes with euclidean, taxicab and chebyshev distances.

Following distance operators introduced:

<#> taxicab distance
<-> euclidean distance
<=> chebyshev distance

For example:
SELECT * FROM objects ORDER BY objects.coord <-> '(137,42,314)'::cube LIMIT 10;

Also there is operator "->" for selecting ordered rows directly from index.
This request selects rows ordered ascending by 3rd coordinate:

SELECT * FROM objects ORDER BY objects.coord->3 LIMIT 10;

For descendent ordering suggested syntax with minus before coordinate.
This request selects rows ordered descending by 4th coordinate:

SELECT * FROM objects ORDER BY objects.coord->-4 LIMIT 10;

Stas Kelvich.

Attachment Content-Type Size
distances.patch application/octet-stream 10.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Fanghaenel 2013-09-23 00:51:26 Comparison semantics of CHAR data type
Previous Message Peter Geoghegan 2013-09-22 22:21:15 Re: INSERT...ON DUPLICATE KEY LOCK FOR UPDATE