From: Ryanhya (@Ryanhya) <noreply+Ryanhya@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #843: Question about the memory allocation when building hnsw index
Date: Fri, 23 May 2025 06:38:40 +0000
Message-ID: <gh-pgvector-pgvector-843@github.com> (raw)
Hi!
I am using pg14 with pgvector to build hnsw index on sift1b dataset on a 4C16GB machine. Obiviously, OOM occurs in the limited environment when processing billion-scale dataset. So I use partial index to test the stress in such an environment.
It was successful that I attempted to use 1 million vectors to build hnsw index. I didn't modify the parameters such as `maintenance_work_mem` and `ef_construction`, they are set to the default value. The memory consumption is about 1.5GB (the peak memory usage is 13%). However, the pg server crashed after just several seconds because of OOM when the vector number increased to 5 million. I am confused about that. Intuitively OOM would not be triggered because of 10% memory usage in 1-million context. So I wonder how the memory is allocated when initializing.
Thanks:).