pg.ddx.io pgvector/pgvector GitHub issues and pull requests
help / color / mirror / Atom feed[pgvector/pgvector] issue #855: Create HNSW Index Before or After Loading Vectors?
3+ messages / 2 participants
[nested] [flat]
* [pgvector/pgvector] issue #855: Create HNSW Index Before or After Loading Vectors?
@ 2025-06-07 08:22 "soukathit (@soukathit)" <noreply+soukathit@github.com>
0 siblings, 0 replies; 3+ messages in thread
From: soukathit (@soukathit) @ 2025-06-07 08:22 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Hi Team,
We would like clarification on the appropriate timing for creating indexes in pgvector. Should the index be created before loading the vector embeddings or after the embeddings are inserted into the store? We've observed some inconsistencies in the query results with both approaches, indicating potential issues.
We are using LlamaIndex to load the embeddings into pgvector. In the full load scenario (as shown in the snippet below), the PGVectorStore.from_params() method first creates the table and associated indexes, and then loads the data:
vector_store = PGVectorStore.from_params(
database=db_name,
host=url.host,
password=url.password,
port=url.port,
user=url.username,
table_name="paul_graham_essay",
embed_dim=1536, # OpenAI embedding dimension
hnsw_kwargs={
"hnsw_m": 16,
"hnsw_ef_construction": 64,
"hnsw_ef_search": 40,
"hnsw_dist_method": "vector_cosine_ops",
},
)
For incremental loads, do we need to manually reindex the HNSW index, or are the HNSW indexes automatically updated as new records are inserted?
^ permalink raw [nested|flat] 3+ messages in thread
* Re: [pgvector/pgvector] issue #855: Create HNSW Index Before or After Loading Vectors?
@ 2025-06-07 08:57 "ankane (@ankane)" <noreply+ankane@github.com>
1 sibling, 0 replies; 3+ messages in thread
From: ankane (@ankane) @ 2025-06-07 08:57 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
HNSW indexes can be created before or after loading data (but it's faster to create them after), and they stay up-to-date as new records are inserted.
^ permalink raw [nested|flat] 3+ messages in thread
* Re: [pgvector/pgvector] issue #855: Create HNSW Index Before or After Loading Vectors?
@ 2025-06-07 08:57 "ankane (@ankane)" <noreply+ankane@github.com>
1 sibling, 0 replies; 3+ messages in thread
From: ankane (@ankane) @ 2025-06-07 08:57 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
@ankane closed this.
^ permalink raw [nested|flat] 3+ messages in thread
end of thread, other threads:[~2025-06-07 08:57 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-06-07 08:22 [pgvector/pgvector] issue #855: Create HNSW Index Before or After Loading Vectors? "soukathit (@soukathit)" <noreply+soukathit@github.com>
2025-06-07 08:57 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-06-07 08:57 ` "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