pg.ddx.io pgvector/pgvector GitHub issues and pull requests
help / color / mirror / Atom feed[pgvector/pgvector] issue #837: hnsw indexing Search Results Become Inconsistent Under High Query Rate
6+ messages / 2 participants
[nested] [flat]
* [pgvector/pgvector] issue #837: hnsw indexing Search Results Become Inconsistent Under High Query Rate
@ 2025-05-14 09:22 "PatwalVineet (@PatwalVineet)" <noreply+PatwalVineet@github.com>
0 siblings, 0 replies; 6+ messages in thread
From: PatwalVineet (@PatwalVineet) @ 2025-05-14 09:22 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Hi, I'm experiencing an issue with pgvector during high search rates.
When performing vector similarity search at a low query rate, everything works as expected — relevant results are consistently returned. However, as the query rate increases (e.g., under concurrent or rapid-fire search conditions), the quality of results degrades significantly. Some expected matches are not returned, and results appear inconsistent.
^ permalink raw [nested|flat] 6+ messages in thread
* Re: [pgvector/pgvector] issue #837: hnsw indexing Search Results Become Inconsistent Under High Query Rate
@ 2025-05-14 09:32 "ankane (@ankane)" <noreply+ankane@github.com>
4 siblings, 0 replies; 6+ messages in thread
From: ankane (@ankane) @ 2025-05-14 09:32 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Hi @PatwalVineet, I don't see how this would happen, but if you're able to create a self-contained, minimal reproducible example with a public dataset, happy to look into it more.
^ permalink raw [nested|flat] 6+ messages in thread
* Re: [pgvector/pgvector] issue #837: hnsw indexing Search Results Become Inconsistent Under High Query Rate
@ 2025-05-14 09:32 "ankane (@ankane)" <noreply+ankane@github.com>
4 siblings, 0 replies; 6+ messages in thread
From: ankane (@ankane) @ 2025-05-14 09:32 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
@ankane closed this.
^ permalink raw [nested|flat] 6+ messages in thread
* Re: [pgvector/pgvector] issue #837: hnsw indexing Search Results Become Inconsistent Under High Query Rate
@ 2025-05-15 04:16 "PatwalVineet (@PatwalVineet)" <noreply+PatwalVineet@github.com>
4 siblings, 0 replies; 6+ messages in thread
From: PatwalVineet (@PatwalVineet) @ 2025-05-15 04:16 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
@ankane
i have provided my table backup link schema is events
https://drive.google.com/file/d/12uKbhhTicaEB7sPvkEdk9b-l2sGMt8eL/view?usp=sharing
```DO $$
DECLARE
rec RECORD;
closest_match UUID;
BEGIN
-- Start a single transaction for the entire process
FOR rec IN
SELECT "Id", "embedding" FROM events."Face_Recognition" ORDER BY "Id" ASC
LOOP
-- Find the closest match where id is less than current id
SELECT "GroupId"
INTO closest_match
FROM (
SELECT "Id","GroupId", "embedding" <=> rec.embedding AS "CosineDistance"
FROM events."Face_Recognition" where "Id"<rec."Id"
) AS Subquery
WHERE "CosineDistance" < 0.5 AND "GroupId" IS NOT NULL
ORDER BY "CosineDistance"
LIMIT 1;
-- If no match found, generate a new UUID
IF closest_match IS NULL THEN
closest_match := uuid_generate_v4();
END IF;
-- Update the current row
UPDATE events."Face_Recognition"
SET "GroupId" = closest_match
WHERE "Id" = rec."Id";
closest_match:=null;
END LOOP;
EXCEPTION WHEN OTHERS THEN
-- Handle errors for the entire process
RAISE NOTICE 'Error processing records: %', SQLERRM;
ROLLBACK;
commit;
END $$;
```
this is the query which i am using to assign groupIds based on vector similarity
in my Face_Recognition table there are 9705 rows having repeated 51 unique vectors so according to this query the output of distinct groupIds should be 51
^ permalink raw [nested|flat] 6+ messages in thread
* Re: [pgvector/pgvector] issue #837: hnsw indexing Search Results Become Inconsistent Under High Query Rate
@ 2025-05-15 05:11 "ankane (@ankane)" <noreply+ankane@github.com>
4 siblings, 0 replies; 6+ messages in thread
From: ankane (@ankane) @ 2025-05-15 05:11 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Hi @PatwalVineet, I won't be able to download files from Google Drive, so please use a public dataset like SIFT or GIST (or generate the data programmatically) and include everything needed to set up the schema, insert the data, run concurrent queries, and measure recall in a single script. Also, please make the query and everything else as minimal as possible.
^ permalink raw [nested|flat] 6+ messages in thread
* Re: [pgvector/pgvector] issue #837: hnsw indexing Search Results Become Inconsistent Under High Query Rate
@ 2025-05-15 07:42 "ankane (@ankane)" <noreply+ankane@github.com>
4 siblings, 0 replies; 6+ messages in thread
From: ankane (@ankane) @ 2025-05-15 07:42 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Also, the HNSW algorithm is not designed for a large percentage of duplicate vectors (which it sounds like may be the case here), so that could be the cause of poor recall.
^ permalink raw [nested|flat] 6+ messages in thread
end of thread, other threads:[~2025-05-15 07:42 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-05-14 09:22 [pgvector/pgvector] issue #837: hnsw indexing Search Results Become Inconsistent Under High Query Rate "PatwalVineet (@PatwalVineet)" <noreply+PatwalVineet@github.com>
2025-05-14 09:32 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-05-14 09:32 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-05-15 04:16 ` "PatwalVineet (@PatwalVineet)" <noreply+PatwalVineet@github.com>
2025-05-15 05:11 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-05-15 07:42 ` "ankane (@ankane)" <noreply+ankane@github.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox