Re: [PATCH] kNN for btree

From: Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, David Steele <david(at)pgmasters(dot)net>, Anastasia Lubennikova <lubennikovaav(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] kNN for btree
Date: 2019-12-03 00:00:03
Message-ID: CAPpHfdsWsb9T1eHdX+r7wnXbGJKQxSffc8gTGp4ZA2ewP49Hog@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 9, 2019 at 11:28 PM Alexander Korotkov
<a(dot)korotkov(at)postgrespro(dot)ru> wrote:
> On Sun, Sep 8, 2019 at 11:35 PM Alexander Korotkov
> <a(dot)korotkov(at)postgrespro(dot)ru> wrote:
> > I'm going to push 0001 changing "attno >= 1" to assert.
>
> Pushed. Rebased patchset is attached. I propose to limit
> consideration during this commitfest to this set of 7 remaining
> patches. The rest of patches could be considered later. I made some
> minor editing in preparation to commit. But I decided I've couple
> more notes to Nikita.
>
> * 0003 extracts part of fields from BTScanOpaqueData struct into new
> BTScanStateData struct. However, there is a big comment regarding
> BTScanOpaqueData just before definition of BTScanPosItem. It needs to
> be revised.
> * 0004 adds "knnState" field to BTScanOpaqueData in addition to
> "state" field. Wherein "knnState" might unused during knn scan if it
> could be done in one direction. This seems counter-intuitive. Could
> we rework this to have "forwardState" and "backwardState" fields
> instead of "state" and "knnState"?

I have reordered patchset into fewer more self-consistent patches.

Besides comments, code beautification and other improvements, now
there are dedicated fields for forward and backward scan states. The
forward scan state is the pointer to data structure, which is used in
ordinal unidirectional scan. So, it's mostly cosmetic change, but it
improves the code readability.

One thing bothers me. We have to move scalar distance operators from
btree_gist to core. btree_gist extension upgrade script have to
qualify operators with schema in order to distinguish core and
extension implementations. So, I have to use @extschema(at)(dot) But it's
forbidden for relocatable extensions. For now, I marken btree_gist as
non-relocatable. Our comment in extension.c says "For a relocatable
extension, we needn't do this. There cannot be any need for
@extschema@, else it wouldn't be relocatable.". Is it really true? I
think now we have pretty valid example for relocatable extension,
which needs @extschema@ in upgrade script. Any thoughts?

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Attachment Content-Type Size
0002-Allow-ordering-by-operator-in-ordered-indexes-v16.patch.gz application/x-gzip 1.8 KB
0003-Extract-BTScanState-from-BTScanOpaqueData-v16.patch.gz application/x-gzip 11.2 KB
0004-Move-scalar-distance-operators-from-btree_gist-t-v16.patch.gz application/x-gzip 12.9 KB
0005-Add-knn-support-to-btree-indexes-v16.patch.gz application/x-gzip 23.1 KB
0001-Introduce-IndexAmRoutine.ammorderbyopfirstcol-v16.patch.gz application/x-gzip 3.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2019-12-03 01:30:35 Re: pgbench -i progress output on terminal
Previous Message Tom Lane 2019-12-02 22:54:11 Re: surprisingly expensive join planning query