pg.ddx.io pgvector/pgvector GitHub issues and pull requestshelp / color / mirror / Atom feed
[pgvector/pgvector] issue #854: Question about the peak memory usage across different datasets 5+ messages / 3 participants [nested] [flat]
* [pgvector/pgvector] issue #854: Question about the peak memory usage across different datasets @ 2025-06-06 09:40 "Ryanhya (@Ryanhya)" <noreply+Ryanhya@github.com> 0 siblings, 0 replies; 5+ messages in thread From: Ryanhya (@Ryanhya) @ 2025-06-06 09:40 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> Hi! I used [SIFT10M](https://big-ann-benchmarks.com/neurips21.html) and [GIST1M](https://github.com/erikbern/ann-benchmarks) to evaluate their memory usage using HNSW with `maintenance_work_mem=8GB`, `max_parallel_maintenance_workers=8`, `m=16` and `ef_construction=64`: |Datasets|Type|Dimension|Base vectors|Data size|Peak memory usage| Final index size | |:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:| |SIFT10M|uint8|128|10,000,000| 10M\*1\*128| 8200MB | 7927MB | |GIST1M|float32|960|1,000,000| 1M\*4\*960| 5359MB | 7685MB | A notification was shown on SIFT10M while no notifications on GIST1M: ``` NOTICE: hnsw graph no longer fits into maintenance_work_mem after 4958138 tuples DETAIL: Building will take significantly more time. HINT: Increase maintenance_work_mem to speed up builds. ``` So the full memory usage of SIFT10M is about 16GB if a larger `maintenance_work_mem` is set (e.g., 32GB). I feel a little bit strange about the memory usage: - Why GIST1M holds a lower peak memory usage than SIFT10M, while its data size is larger than SIFT10M? - And why GIST1M's peak memory usage is less than its index size if no above notifications appear? ^ permalink raw [nested|flat] 5+ messages in thread
* Re: [pgvector/pgvector] issue #854: Question about the peak memory usage across different datasets @ 2025-06-06 11:52 ` "jkatz (@jkatz)" <noreply+jkatz@github.com> 3 siblings, 0 replies; 5+ messages in thread From: jkatz (@jkatz) @ 2025-06-06 11:52 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> Which pgvector data type did you use? `vector` uses 4-byte floats, but your math is using 1-byte uint. ^ permalink raw [nested|flat] 5+ messages in thread
* Re: [pgvector/pgvector] issue #854: Question about the peak memory usage across different datasets @ 2025-06-06 12:12 ` "Ryanhya (@Ryanhya)" <noreply+Ryanhya@github.com> 3 siblings, 0 replies; 5+ messages in thread From: Ryanhya (@Ryanhya) @ 2025-06-06 12:12 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> Both SIFT10M and GIST1M are using `vector` type: ``` CREATE TABLE gist1m(id bigint, embedding vector(960)); CREATE TABLE sift10m(id bigint, embedding vector(128)); ``` Data size here refers to the size of the entire dataset. Although SIFT10M uses 4 bytes here for each dimension in pgvector, their memory usage should be close to each other intuitively. ^ permalink raw [nested|flat] 5+ messages in thread
* Re: [pgvector/pgvector] issue #854: Question about the peak memory usage across different datasets @ 2025-06-06 20:36 ` "ankane (@ankane)" <noreply+ankane@github.com> 3 siblings, 0 replies; 5+ messages in thread From: ankane (@ankane) @ 2025-06-06 20:36 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> Hi @Ryanhya, with 4-byte elements, SIFT10M is larger than GIST1M, which is why the in-memory index build will use more memory (there are also more tuples, which will use more memory). However, the final GIST index will have a lot of wasted space (since it's 960 dimensions, so only one vector + neighbors will fit on an 8 KB page), which is why the difference isn't reflected in the final size (this is also why the final size is larger than the in-memory size for this dataset). ^ permalink raw [nested|flat] 5+ messages in thread
* Re: [pgvector/pgvector] issue #854: Question about the peak memory usage across different datasets @ 2025-06-06 20:36 ` "ankane (@ankane)" <noreply+ankane@github.com> 3 siblings, 0 replies; 5+ messages in thread From: ankane (@ankane) @ 2025-06-06 20:36 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> @ankane closed this. ^ permalink raw [nested|flat] 5+ messages in thread
end of thread, other threads:[~2025-06-06 20:36 UTC | newest] Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2025-06-06 09:40 [pgvector/pgvector] issue #854: Question about the peak memory usage across different datasets "Ryanhya (@Ryanhya)" <noreply+Ryanhya@github.com> 2025-06-06 11:52 ` "jkatz (@jkatz)" <noreply+jkatz@github.com> 2025-06-06 12:12 ` "Ryanhya (@Ryanhya)" <noreply+Ryanhya@github.com> 2025-06-06 20:36 ` "ankane (@ankane)" <noreply+ankane@github.com> 2025-06-06 20:36 ` "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