pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] issue #909: Optimising Insert+Index creation time
4+ messages / 3 participants
[nested] [flat]

* [pgvector/pgvector] issue #909: Optimising Insert+Index creation time
@ 2025-10-10 12:13  "aasneh-prasad-glean (@aasneh-prasad-glean)" <noreply+aasneh-prasad-glean@github.com>
  0 siblings, 0 replies; 4+ messages in thread

From: aasneh-prasad-glean (@aasneh-prasad-glean) @ 2025-10-10 12:13 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi folks,

Firstly, I appreciate the pgvector team's work on this excellent software.

I'm currently evaluating pgvector as a vector DB solution and need to optimize the loading+index building time. My current workflow consists of:

1.  Inserting embeddings and metadata using the `CREATE TABLE` command.
2.  Performing HNSW indexing in the background with the `CREATE INDEX CONCURRENTLY` command.
    - dimension of vectors: 128
    - ef_construction: 600
    - m: 64

My setup involves a `db-custom-2-8192` machine (2 Vcpus, 8 GB RAM, 100 GB SSD), and I'm loading approximately 1.5M vectors. Step 1 takes about 1.7 hours, while Step 2 takes about 12 hours. The peak RAM usage was 6.11 GB, with a final usage of around 3.6 GB.

Given that we intend to use a machine type with close to 8 GB of RAM, what parameter tuning or configuration adjustments can be made to reduce the loading and indexing times?




^ permalink  raw  [nested|flat] 4+ messages in thread

* Re: [pgvector/pgvector] issue #909: Optimising Insert+Index creation time
@ 2025-10-10 12:18  "aasneh-prasad-glean (@aasneh-prasad-glean)" <noreply+aasneh-prasad-glean@github.com>
  2 siblings, 0 replies; 4+ messages in thread

From: aasneh-prasad-glean (@aasneh-prasad-glean) @ 2025-10-10 12:18 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@aasneh-prasad-glean renamed this.

^ permalink  raw  [nested|flat] 4+ messages in thread

* Re: [pgvector/pgvector] issue #909: Optimising Insert+Index creation time
@ 2025-10-10 13:39  "jkatz (@jkatz)" <noreply+jkatz@github.com>
  2 siblings, 0 replies; 4+ messages in thread

From: jkatz (@jkatz) @ 2025-10-10 13:39 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@aasneh-prasad-glean I suggest watching [this video](youtube.com/watch?v=L8fQqVwTT3Y&ab_channel=AWSEvents) (or any one of the ones [listed here](https://jkatz05.com/talks/) for guidance on this, as this covers best practices, including parameter tuning. (Which reminds me, I have some newer versions of the talk to publish)

tl;dr:
* If you're bulk loading, first load the vectors, then build the index
* Use `COPY ... WITH (FORMAT BINARY)`  when loading the vectors, this will speed things up
* With the index, start with the default parameters (m=16, ef_construction=64) and only adjust if you're not getting your target search relevancy
* Adjust `maintenance_work_mem` to try to fit your vector set, with some overhead for the HNSW index. I use a factor of 1.3. So for the above, assuming no quantization: `(1.3 * 1500000 * (8 + 4 * 128)) / 1024**3` = ~1GB of `maintenance_work_mem`. A higher `m` will require more.
* Because you only have 2 vCPU, you should use more than two parallel workers for the build.


^ permalink  raw  [nested|flat] 4+ messages in thread

* Re: [pgvector/pgvector] issue #909: Optimising Insert+Index creation time
@ 2025-10-10 18:11  "ankane (@ankane)" <noreply+ankane@github.com>
  2 siblings, 0 replies; 4+ messages in thread

From: ankane (@ankane) @ 2025-10-10 18:11 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ankane closed this.

^ permalink  raw  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2025-10-10 18:11 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-10-10 12:13 [pgvector/pgvector] issue #909: Optimising Insert+Index creation time "aasneh-prasad-glean (@aasneh-prasad-glean)" <noreply+aasneh-prasad-glean@github.com>
2025-10-10 12:18 ` "aasneh-prasad-glean (@aasneh-prasad-glean)" <noreply+aasneh-prasad-glean@github.com>
2025-10-10 13:39 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2025-10-10 18:11 ` "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