From: jkatz (@jkatz) <noreply+jkatz@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #500: Index Build Time Does Not Improve as Expected When Changing "Workers"
Date: Tue, 24 Sep 2024 14:26:52 +0000
Message-ID: <gh-pgvector-pgvector-500-c2371460628@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-500@github.com>
References: <gh-pgvector-pgvector-500@github.com>
@schuemie It depends on the dataset, and if you're indexing the full vectors (no quantization), you'll need roughly 1.3x the size of the dataset of memory. So using the above dataset and very rough math (not accounting for page size here, which adds a bit more), you'd ~137GiB to hold the full set in memory:
```
SELECT (1.3 * (37000000::numeric * (768 * 4 + 8))) / 1024^3;
```
Thus, as Andrew suggests, partitioning the data would help reduce the overall amount of memory required. Given you need memory for other database operations and your shared buffers (I'll assume your shared buffers are set to `20GB`), let's say you set `maintenace_work_mem` to `20GB` - you can then build the dataset over 8 partitions while keeping the index in memory (again, rough math).