From: tamis-laan (@tamis-laan) <noreply+tamis-laan@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #554: Support for multiquery?
Date: Fri, 10 May 2024 14:15:04 +0000
Message-ID: <gh-pgvector-pgvector-554-c2104687939@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-554@github.com>
References: <gh-pgvector-pgvector-554@github.com>
Thnx @ankane, that is exactly the problem I'm trying to solve (@jkatz). However my query would consist of 4000+ vectors I all would like to match. A query like:
``` sql
(SELECT 1 AS query, * FROM items ORDER BY embedding <-> '[1,2,3]' LIMIT 1)
UNION ALL
.
.
.
(SELECT 2 AS query, * FROM items ORDER BY embedding <-> '[4,5,6]' LIMIT 1);
```
would probably become very inefficient. So I was wondering can't we pass in a matrix where each row is a vector to be queried. Something like:
``` sql
SELECT * FROM items ORDER BY embedding <-> '[[1,2,3],...,[4,5,6]]' LIMIT 100;
```
I can imagine this would be way more efficient given that blocks of memory need to be loaded in and out of memory by postgresql in order to do the distance calculation. My database would be ~100GiB in size. My dataset would be much larger, but I'm planning to use multiple databases.