Re: [PATCH] kNN for btree - Mailing list pgsql-hackers

From Alexander Korotkov
Subject Re: [PATCH] kNN for btree
Date
Msg-id CAPpHfdu6o6y8fv3Ep6j8qtfi3DtHyqCikvLXvgEEYYD7mkfSQg@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] kNN for btree  (Alexander Korotkov <a.korotkov@postgrespro.ru>)
Responses Re: [PATCH] kNN for btree  (Nikita Glukhov <n.gluhov@postgrespro.ru>)
List pgsql-hackers
Hi!

I've couple more notes regarding this patch.
1) There are two loops over scan key determining scan strategy:
existing loop in _bt_first(), and in new function
_bt_select_knn_search_strategy().  It's kind of redundant that we've
to process scan keys twice for knn searches.  I think scan keys
processing should be merged into one loop.
2) We're not supporting knn ordering only using the first key.
Supporting multiple knn keys would require significant reword of
B-tree traversal algorithm making it closer to GiST and SP-GiST.  So,
I think supporting only one knn key is reasonable restriction, at
least for now.  But we could support single-key knn ordering in more
cases.  For instance, knn search in "SELECT * FROM tbl WHERE a =
const1 ORDER BY b <-> const2" could benefit from (a, b) B-tree index.
So, we can support knn search on n-th key if there are equality scan
keys for [1, n-1] index keys.

I've already discussed these issues with Nikita personally.
Hopefully, new version will be published soon.

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


pgsql-hackers by date:

Previous
From: John Naylor
Date:
Subject: Re: unnecessary creation of FSM files during bootstrap mode
Next
From: Peter Geoghegan
Date:
Subject: Re: MERGE SQL statement for PG12