From: developerayuva (@developerayuva) <noreply+developerayuva@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #844: Questions on HNSW graph memory usage and size estimation
Date: Sun, 25 May 2025 05:50:22 +0000
Message-ID: <gh-pgvector-pgvector-844@github.com> (raw)
Hi team,
Thanks for the great work on `pgvector`! I had a couple of questions related to HNSW index builds:
- When building an HNSW index, I saw the following notice:
```
NOTICE: hnsw graph no longer fits into maintenance_work_mem after 5908085 tuples
DETAIL: Building will take significantly more time.
HINT: Increase maintenance_work_mem to speed up builds.
```
Is there a way to **estimate in advance** how much `maintenance_work_mem` is required so that the HNSW graph can fully fit into memory during index creation? This would help avoid performance hits and tune the setting properly.
- Once the index build is complete, is there a way to **check the size of the HNSW graph** that was built? Is it equivalent to the index size shown by `pg_relation_size()`, or is the actual graph size stored separately?
Thanks