pg.ddx.io pgvector/pgvector GitHub issues and pull requests
help / color / mirror / Atom feed[pgvector/pgvector] issue #688: HNSW Index Size Constant with Different Index Build Params
3+ messages / 3 participants
[nested] [flat]
* [pgvector/pgvector] issue #688: HNSW Index Size Constant with Different Index Build Params
@ 2024-10-01 09:44 "wahajali (@wahajali)" <noreply+wahajali@github.com>
0 siblings, 0 replies; 3+ messages in thread
From: wahajali (@wahajali) @ 2024-10-01 09:44 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
I'm am using an OpenAI 1536 dim (500K) dataset provided by VectorDBBench - a benchmarking tool for vector database. I've run several test with different index build parameters, but for this particular dataset I noticed that the index size remains constant:
I have used the following index build parameters all resulting in a index size of 3906MB:
m=16, ef_construction=128
m=16, ef_construction=32
m=16, ef_construction=64
m=32, ef_construction=128
m=32, ef_construction=64
m=8, ef_construction=128
m=8, ef_construction=32
m=8, ef_construction=64
This seems counterintuitive. I also saw this [post](https://jkatz05.com/post/postgres/pgvector-hnsw-performance/#:~:text=There%E2%80%99s%20likely%20wor-...) by one of the contributors, that shares similar observations for another OpenAI dataset (dbpedia-openai-1000k-angular (1M, 1536-dim)).
Is there an explanation on why the index might result in the same size even with different params?
I use the following command to get the index size:
```
SELECT pg_size_pretty(pg_table_size('table_name')) as table_size, pg_size_pretty(pg_table_size('index_name')) as index_size;
```
^ permalink raw [nested|flat] 3+ messages in thread
* Re: [pgvector/pgvector] issue #688: HNSW Index Size Constant with Different Index Build Params
@ 2024-10-01 14:06 "jkatz (@jkatz)" <noreply+jkatz@github.com>
1 sibling, 0 replies; 3+ messages in thread
From: jkatz (@jkatz) @ 2024-10-01 14:06 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
@wahajali The overall size of the index is affected by how much data you can fit into a PostgreSQL index page, which is 8KB (8192 bytes) in size.
`m` impacts the number of links being maintained between tuples (vectors) in the graph. The actually size of the links is pretty small (bytes) - so increasing `m` won't add too much to each entry, particularly if your vectors take up most of the page (an unquantized 1,536 dim vector takes up 6KiB, so it will use the entirety of an index page, so it takes up 8KiB in the index).
`ef_construction` is only used while inserting a tuple (vector) into the index, as this maintains the list of "closest neighbors" - this impacts index construction, but not size.
^ permalink raw [nested|flat] 3+ messages in thread
* Re: [pgvector/pgvector] issue #688: HNSW Index Size Constant with Different Index Build Params
@ 2024-10-01 16:31 "ankane (@ankane)" <noreply+ankane@github.com>
1 sibling, 0 replies; 3+ messages in thread
From: ankane (@ankane) @ 2024-10-01 16:31 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
@ankane closed this.
^ permalink raw [nested|flat] 3+ messages in thread
end of thread, other threads:[~2024-10-01 16:31 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-10-01 09:44 [pgvector/pgvector] issue #688: HNSW Index Size Constant with Different Index Build Params "wahajali (@wahajali)" <noreply+wahajali@github.com>
2024-10-01 14:06 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2024-10-01 16:31 ` "ankane (@ankane)" <noreply+ankane@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