From: ldhasson (@ldhasson) <noreply+ldhasson@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #569: Duplicate error when creating a vector index using HNSW
Date: Sat, 25 May 2024 00:51:08 +0000
Message-ID: <gh-pgvector-pgvector-569@github.com> (raw)
Hello all,
We are on PG 15.5 using pgvector 0,6. We have a table defined as such:
```sql
CREATE TABLE genai_embeddings.pubmed_cardiac_oncology_diabetes (
id SERIAL PRIMARY KEY,
pmid VARCHAR(50),
summary_text TEXT,
chunk_embedding VECTOR(768)
);
```
We loaded approximately 3.1M records on a GCP SQL Instance with 8 cores and 32GB memory. Then we created the following index:
```sql
CREATE INDEX ON embeddings.mydoccuments USING hnsw (chunk_embedding vector_cosine_ops);
```
There was no activity on the DB so no new records were added or anything like that. After almost 4 hours, we got the following error:
```log
ERROR: duplicate key value violates unique constraint "pg_class_relname_nsp_index"
DETAIL: Key (relname, relnamespace)=(mydoccuments_chunk_embeddings_idx1, 775711) already exists.
```
It is possible that there is a duplicate document, but would this be an issue? We created an index and not a unique index. We are also chunking by paragraph and some paragraphs are common boiler plates in the documents too.
Additionally, would one expect the index to take 4h to build for a 3.1M row table with VECTOR(768)?
Thank you,
Laurent.