pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: jkatz (@jkatz) <noreply+jkatz@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #745: Automate estimation of amount of memory needed for fast HNSW index build
Date: Tue, 31 Dec 2024 04:25:35 +0000
Message-ID: <gh-pgvector-pgvector-745-c2566121887@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-745@github.com>
References: <gh-pgvector-pgvector-745@github.com>

Thanks for the suggestion.

The rough math I typically use is `# vectors * sizeof(VECTOR) * 1.3`, where `VECTOR` is the data type size (e.g. `vector(1024)` would be `1024*4 + 8`).

So for example, if I have 1,000,000 1024-dim fp32 vectors, the math would be:

```
1000000 * (1024 * 4 + 8) * 1.3 => 5,335,200,000
```

which to get into GiB would be:

```
5,335,200,000 / 1024**3 => ~4.96GB
```

This can get more nuanced due to page alignment (i.e. how many vectors can fit within 8KB), how many layers you have (which is dictated by `m`), and quantization, but I at least wanted to give you a simple formula to start with.

view thread (9+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-745-c2566121887@github.com>
Permalink:  ../gh-pgvector-pgvector-745-c2566121887@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