Re: BUG #6399: knngist sometimes returns tuples in incorrect order

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Cc: yamt(at)mwd(dot)biglobe(dot)ne(dot)jp, oleg(at)sai(dot)msu(dot)su, teodor(at)sigaev(dot)ru
Subject: Re: BUG #6399: knngist sometimes returns tuples in incorrect order
Date: 2012-01-18 14:37:51
Message-ID: 4F16D93F.7090907@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 18.01.2012 14:07, Heikki Linnakangas wrote:
> For 9.2, I think we should change gist so
> that the user-defined distance function can return any scalar data type,
> not just float8 (as long as it has b-tree comparison operators).

I took a shot at doing that. Patch attached. It needs some cleanup; I
think we'll need to bump the version of the btree_gist extension, and I
only changed the btree_int8 distance function to do that, even though it
would now make a lot of sense to adjust the others, too. Also, I think
it'll leak memory (or crash..) if the distance data type is pass-by-ref.

If someone has a test suite at hand for performance testing this, that
would be good. Now that I'm calling the b-tree comparison function for
every comparison operation in the red-black tree, instead of a direct
float8 <= instruction, this could be quite a bit slower. That could be
mitigated somewhat by using the sort-support stuff Tom committed recently.

If we bend things a bit, this might be back-patchable to 9.1. We can't
add a new am support function easily, that would require a catalog
update to increment pg_am.amsupport entry, but we could hardwire the
support for int8 distances, like I hardwired the knowledge of float8's
comparsion function in the attached patch.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

Attachment Content-Type Size
knngist-distance-datatype-1.patch text/x-diff 16.6 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2012-01-18 14:49:34 Re: pg_upgrade v9.1 issues
Previous Message knoch 2012-01-18 13:38:25 BUG #6400: function arguments not accepted