From: JWDobken (@JWDobken) <noreply+JWDobken@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #877: Slow Inserts with HNSW Index — Is Full Reindexing Occurring?
Date: Tue, 22 Jul 2025 14:48:36 +0000
Message-ID: <gh-pgvector-pgvector-877@github.com> (raw)
Hi and thanks for the great work on pgvector !!!
I'm experiencing significantly slower insert performance (~5x) when an HNSW index is present. My current workaround is to temporarily drop the index and recreate it afterward (resulting in system downtime):
```sql
-- Drop index before inserts
DROP INDEX my_vector_hnsw_idx;
-- Recreate it after inserts
CREATE INDEX my_vector_hnsw_idx ON public.lovely_information
USING hnsw (((subvector(my_vector, 1, 1536))::halfvec(1536)) halfvec_cosine_ops)
WITH (m='16', ef_construction='64');
```
Is there a better way to mitigate this slowdown?
Specifically:
- What does the HNSW index do when inserting new vectors?
- Is it incrementally updating the index or triggering some form of reindexing for each insert?
Any advice or configuration tuning tips would be appreciated!
Thanks!