pg.ddx.io pgvector/pgvector GitHub issues and pull requestshelp / color / mirror / Atom feed
[pgvector/pgvector] issue #843: Question about the memory allocation when building hnsw index 7+ messages / 2 participants [nested] [flat]
* [pgvector/pgvector] issue #843: Question about the memory allocation when building hnsw index @ 2025-05-23 06:38 "Ryanhya (@Ryanhya)" <noreply+Ryanhya@github.com> 0 siblings, 0 replies; 7+ messages in thread From: Ryanhya (@Ryanhya) @ 2025-05-23 06:38 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> 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:). ^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgvector/pgvector] issue #843: Question about the memory allocation when building hnsw index @ 2025-05-23 06:56 "ankane (@ankane)" <noreply+ankane@github.com> 5 siblings, 0 replies; 7+ messages in thread From: ankane (@ankane) @ 2025-05-23 06:56 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> Hi @Ryanhya, the index build itself shouldn't use more than `maintenance_work_mem` (you'll also see memory usage from shared buffers, connections, etc.), so it's likely another issue with your setup. I'd check that `shared_buffers` and [other settings](https://github.com/pgvector/pgvector?tab=readme-ov-file#tuning) are correctly set. ^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgvector/pgvector] issue #843: Question about the memory allocation when building hnsw index @ 2025-05-23 06:56 "ankane (@ankane)" <noreply+ankane@github.com> 5 siblings, 0 replies; 7+ messages in thread From: ankane (@ankane) @ 2025-05-23 06:56 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> @ankane closed this. ^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgvector/pgvector] issue #843: Question about the memory allocation when building hnsw index @ 2025-05-23 06:58 "ankane (@ankane)" <noreply+ankane@github.com> 5 siblings, 0 replies; 7+ messages in thread From: ankane (@ankane) @ 2025-05-23 06:58 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> Also, if you're trying to build a large index, I'd highly recommend following [the advice](https://github.com/pgvector/pgvector?tab=readme-ov-file#index-build-time) from the docs. ^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgvector/pgvector] issue #843: Question about the memory allocation when building hnsw index @ 2025-05-23 08:45 "Ryanhya (@Ryanhya)" <noreply+Ryanhya@github.com> 5 siblings, 0 replies; 7+ messages in thread From: Ryanhya (@Ryanhya) @ 2025-05-23 08:45 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> @ankane Thanks! Actually I check that `maintenance_work_mem` is set to 1GB when using 1 million vectors (the memory usage is about 1.5 GB), so it seems that the consumption could be a little bit greater than the value? Is there a threshold for the portion exceeding this value? ^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgvector/pgvector] issue #843: Question about the memory allocation when building hnsw index @ 2025-05-23 08:51 "ankane (@ankane)" <noreply+ankane@github.com> 5 siblings, 0 replies; 7+ messages in thread From: ankane (@ankane) @ 2025-05-23 08:51 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> The additional memory is likely from other sources like shared buffers, as mentioned above. ^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgvector/pgvector] issue #843: Question about the memory allocation when building hnsw index @ 2025-05-23 09:07 "Ryanhya (@Ryanhya)" <noreply+Ryanhya@github.com> 5 siblings, 0 replies; 7+ messages in thread From: Ryanhya (@Ryanhya) @ 2025-05-23 09:07 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> @ankane I see. Thank you:)! ^ permalink raw [nested|flat] 7+ messages in thread
end of thread, other threads:[~2025-05-23 09:07 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2025-05-23 06:38 [pgvector/pgvector] issue #843: Question about the memory allocation when building hnsw index "Ryanhya (@Ryanhya)" <noreply+Ryanhya@github.com> 2025-05-23 06:56 ` "ankane (@ankane)" <noreply+ankane@github.com> 2025-05-23 06:56 ` "ankane (@ankane)" <noreply+ankane@github.com> 2025-05-23 06:58 ` "ankane (@ankane)" <noreply+ankane@github.com> 2025-05-23 08:45 ` "Ryanhya (@Ryanhya)" <noreply+Ryanhya@github.com> 2025-05-23 08:51 ` "ankane (@ankane)" <noreply+ankane@github.com> 2025-05-23 09:07 ` "Ryanhya (@Ryanhya)" <noreply+Ryanhya@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