From: knizhnik (@knizhnik) <noreply+knizhnik@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] PR #282: Hnsw iterator
Date: Sat, 30 Sep 2023 11:51:47 +0000
Message-ID: <gh-pgvector-pgvector-282-c1741748906@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-282@github.com>
References: <gh-pgvector-pgvector-282@github.com>
> I want to bring up this topic that I also wrote in a comment on my branch:
Another type of query which can suffer from order violation is group by:
```
explain select string_agg(_id,',') from (select _id,openai_vector <-> array[1,2,3]::vector as dist from documents order by dist limit 1000) group by dist;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------
GroupAggregate (cost=645.20..2711.52 rows=200 width=40)
Group Key: ((documents.openai_vector <-> '[1,2,3]'::vector))
-> Limit (cost=645.20..2704.02 rows=1000 width=37)
-> Index Scan using documents_openai_vector_idx on documents (cost=645.20..2059465.20 rows=1000000 width=37)
Order By: (openai_vector <-> '[1,2,3]'::vector)
(5 rows)
```
Frtankly speaking I do not have any good proposal of solving this problem. Both series seems to be very artificial and unlikely that any user will be faced with this problem. The concept of approximate search contradicts SQL standard fro the very begging: result of query plan using index may be different from query plan not using index. If we are not able to provide precise results, then order of this results seems to be less critical problem, doesn't it?