pg.ddx.io pgvector/pgvector GitHub issues and pull requests
help / color / mirror / Atom feed[pgvector/pgvector] issue #725: HNSW Index Bypassed Based On Table Size?
5+ messages / 2 participants
[nested] [flat]
* [pgvector/pgvector] issue #725: HNSW Index Bypassed Based On Table Size?
@ 2024-12-03 21:24 "daviddanialy (@daviddanialy)" <noreply+daviddanialy@github.com>
0 siblings, 0 replies; 5+ messages in thread
From: daviddanialy (@daviddanialy) @ 2024-12-03 21:24 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
I have two tables with 2000-length vector columns. One table (embeddings) has 13,000 rows and the other (image_prompt_embedding) has 7,500,000. Running the exact same query:
`EXPLAIN SELECT *
FROM embeddings ipe
ORDER BY ipe.sidekick_embedding <-> ${embedding}::vector
LIMIT 5;`
`EXPLAIN SELECT *
FROM image_prompt_embedding ipe
ORDER BY embedding <-> ${embedding}::vector
LIMIT 5;`
on both tables yields different results:
Limit (cost=572.60..573.04 rows=5 width=83)
-> Index Scan using idx_embeddings_vector on embeddings ipe (cost=572.60..1702.65 rows=12964 width=83)
Order By: (sidekick_embedding <-> vector)
Limit (cost=163578.48..163579.07 rows=5 width=50)
-> Gather Merge (cost=163578.48..899400.09 rows=6306602 width=50)
Workers Planned: 2
-> Sort (cost=162578.46..170461.71 rows=3153301 width=50)
Sort Key: ((embedding <-> vector))
-> Parallel Seq Scan on image_prompt_embedding ipe (cost=0.00..110203.26 rows=3153301 width=50)
Both of the HNSW indices were created as such:
`CREATE INDEX idx_name ON table USING hnsw (embedding vector_l2_ops);`
Is this an issue with the table size or something else?
^ permalink raw [nested|flat] 5+ messages in thread
* Re: [pgvector/pgvector] issue #725: HNSW Index Bypassed Based On Table Size?
@ 2024-12-04 13:25 "ankane (@ankane)" <noreply+ankane@github.com>
3 siblings, 0 replies; 5+ messages in thread
From: ankane (@ankane) @ 2024-12-04 13:25 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Hi @daviddanialy, what's the output of `EXPLAIN (ANALYZE, SETTINGS)` for the 2nd query with `SET enable_seqscan = off;`?
^ permalink raw [nested|flat] 5+ messages in thread
* Re: [pgvector/pgvector] issue #725: HNSW Index Bypassed Based On Table Size?
@ 2024-12-04 17:34 "daviddanialy (@daviddanialy)" <noreply+daviddanialy@github.com>
3 siblings, 0 replies; 5+ messages in thread
From: daviddanialy (@daviddanialy) @ 2024-12-04 17:34 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
> Hi @daviddanialy, what's the output of `EXPLAIN (ANALYZE, SETTINGS)` for the 2nd query with `SET enable_seqscan = off;`?
```Limit (cost=10000291209.90..10000291209.91 rows=5 width=50)
-> Sort (cost=10000291209.90..10000310137.73 rows=7571131 width=50)
Sort Key: ((embedding <-> vector))
-> Seq Scan on image_prompt_embedding ipe (cost=10000000000.00..10000165456.14 rows=7571131 width=50)
^ permalink raw [nested|flat] 5+ messages in thread
* Re: [pgvector/pgvector] issue #725: HNSW Index Bypassed Based On Table Size?
@ 2024-12-04 17:46 "ankane (@ankane)" <noreply+ankane@github.com>
3 siblings, 0 replies; 5+ messages in thread
From: ankane (@ankane) @ 2024-12-04 17:46 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
It looks like there isn't an index on that table and column for L2 distance.
^ permalink raw [nested|flat] 5+ messages in thread
* Re: [pgvector/pgvector] issue #725: HNSW Index Bypassed Based On Table Size?
@ 2024-12-04 17:46 "ankane (@ankane)" <noreply+ankane@github.com>
3 siblings, 0 replies; 5+ messages in thread
From: ankane (@ankane) @ 2024-12-04 17:46 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
@ankane closed this.
^ permalink raw [nested|flat] 5+ messages in thread
end of thread, other threads:[~2024-12-04 17:46 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-12-03 21:24 [pgvector/pgvector] issue #725: HNSW Index Bypassed Based On Table Size? "daviddanialy (@daviddanialy)" <noreply+daviddanialy@github.com>
2024-12-04 13:25 ` "ankane (@ankane)" <noreply+ankane@github.com>
2024-12-04 17:34 ` "daviddanialy (@daviddanialy)" <noreply+daviddanialy@github.com>
2024-12-04 17:46 ` "ankane (@ankane)" <noreply+ankane@github.com>
2024-12-04 17:46 ` "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