From: hzhua (@hzhua) <noreply+hzhua@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #731: Building of hnsw sparse index is very slow
Date: Tue, 10 Dec 2024 06:06:01 +0000
Message-ID: <gh-pgvector-pgvector-731@github.com> (raw)
I'm building both dense index and sparse index for about 5 million records. The dense and sparse vectors are generated from BGE-m3, whose dense embedding has a dimension of 1024, and sparse embedding has a dimension of 250002.
```
SET max_parallel_maintenance_workers = 15;
SET maintenance_work_mem = '32GB';
CREATE INDEX IF NOT EXISTS report_sparse_hnsw_idx
ON vector_report
USING hnsw (sparse_vector sparsevec_cosine_ops)
WITH (m = 48, ef_construction = 96)
CREATE INDEX IF NOT EXISTS report_dense_hnsw_idx
ON vector_report
USING hnsw (dense_vector vector_cosine_ops)
WITH (m = 48, ef_construction = 96)
````
With the same hnsw parameters, the building of dense index is fast (<30 mins), but the sparse index is very slow (the building progress is only 36% in one hour).