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: 2020-03-02 21:26:32
Message-ID: CAPpHfdud9V+PEHYXTdhjyHOaZJs7RJj+4+Mbc1CZr__TmTw4aQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 3, 2019 at 3:00 AM Alexander Korotkov
<a(dot)korotkov(at)postgrespro(dot)ru> wrote:
> 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?

I've rebased the patchset to the current master and made some
refactoring. I hope it would be possible to bring it to committable
shape during this CF. This need more refactoring though.

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

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2020-03-02 21:57:55 Re: Portal->commandTag as an enum
Previous Message Jesse Zhang 2020-03-02 20:45:21 Re: Use compiler intrinsics for bit ops in hash