pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: soukathit (@soukathit) <noreply+soukathit@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #855: Create HNSW Index Before or After Loading Vectors?
Date: Sat, 07 Jun 2025 08:22:58 +0000
Message-ID: <gh-pgvector-pgvector-855@github.com> (raw)

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?

view thread (3+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-855@github.com>
Permalink:  ../gh-pgvector-pgvector-855@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