pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] issue #949: HNSW partitions and parameters
4+ messages / 2 participants
[nested] [flat]

* [pgvector/pgvector] issue #949: HNSW partitions and parameters
@ 2026-01-21 19:02 "brycechesternewman (@brycechesternewman)" <noreply+brycechesternewman@github.com>
  0 siblings, 0 replies; 4+ messages in thread

From: brycechesternewman (@brycechesternewman) @ 2026-01-21 19:02 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hello,
Let's say I have a 234(bit) binary value for 250 million rows. I want to split those rows into partitions, so that each partition has 10 million 234(bit) rows. I am splitting the data into partitions so when I build the hnsw index for each partition I don't require huge amounts of memory for maintenance_work_mem, work_mem, etc.
What I am not sure of is how should I set the set the HNSW parameters. 

You can see below I am setting the same hnsw parameters for each index. The first `ix_perceptual_hash` index has no overhead(aka nothing is being indexed yet), but the others index the 234(bit) binary values.

```
CREATE INDEX IF NOT EXISTS ix_perceptual_hash ON ONLY Hashes USING hnsw (perceptualHash bit_hamming_ops) WITH (m = 64, ef_construction = 256);

CREATE INDEX CONCURRENTLY imagehashes_p0_perceptualhash_idx ON Hashes_p0 USING hnsw (perceptualHash bit_hamming_ops) WITH (m = 16, ef_construction = 128);
ALTER INDEX ix_perceptual_hash ATTACH PARTITION imagehashes_p0_perceptualhash_idx;

CREATE INDEX CONCURRENTLY imagehashes_p1_perceptualhash_idx ON Hashes_p1 USING hnsw (perceptualHash bit_hamming_ops) WITH (m = 16, ef_construction = 128);
ALTER INDEX ix_perceptual_hash ATTACH PARTITION imagehashes_p1_perceptualhash_idx;
...
```

Once all partitioned indexes are attached to `ix_perceptual_hash` index there will be 350 million 234(bit) indexed rows.
Should the partitioned indexes have the same hnsw parameters values as `ix_perceptual_hash` partition or smaller hnsw parameters values?

Thank you for your time.

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

* Re: [pgvector/pgvector] issue #949: HNSW partitions and parameters
@ 2026-01-22 00:38 ` "ankane (@ankane)" <noreply+ankane@github.com>
  2 siblings, 0 replies; 4+ messages in thread

From: ankane (@ankane) @ 2026-01-22 00:38 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi @brycechesternewman, I'd recommend using the default parameters unless seeing low recall.

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

* Re: [pgvector/pgvector] issue #949: HNSW partitions and parameters
@ 2026-01-22 00:38 ` "ankane (@ankane)" <noreply+ankane@github.com>
  2 siblings, 0 replies; 4+ messages in thread

From: ankane (@ankane) @ 2026-01-22 00:38 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ankane closed this.

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

* Re: [pgvector/pgvector] issue #949: HNSW partitions and parameters
@ 2026-01-22 15:38 ` "brycechesternewman (@brycechesternewman)" <noreply+brycechesternewman@github.com>
  2 siblings, 0 replies; 4+ messages in thread

From: brycechesternewman (@brycechesternewman) @ 2026-01-22 15:38 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi @ankane,
Thanks for responding.
We are already using the default parameters and seeing low recall. 
The question is do I need different hnsw parameters for the `ix_perceptual_hash` index vs the partitioned indexes?

As an hnsw parameters example...

Is this correct?
```
CREATE INDEX IF NOT EXISTS ix_perceptual_hash ON ONLY Hashes USING hnsw (perceptualHash bit_hamming_ops) WITH (m = 64, ef_construction = 256);

CREATE INDEX CONCURRENTLY imagehashes_p0_perceptualhash_idx ON Hashes_p0 USING hnsw (perceptualHash bit_hamming_ops) WITH (m = 16, ef_construction = 128);
ALTER INDEX ix_perceptual_hash ATTACH PARTITION imagehashes_p0_perceptualhash_idx;

CREATE INDEX CONCURRENTLY imagehashes_p1_perceptualhash_idx ON Hashes_p1 USING hnsw (perceptualHash bit_hamming_ops) WITH (m = 16, ef_construction = 128);
ALTER INDEX ix_perceptual_hash ATTACH PARTITION imagehashes_p1_perceptualhash_idx;
...
```

or this?

```
CREATE INDEX IF NOT EXISTS ix_perceptual_hash ON ONLY Hashes USING hnsw (perceptualHash bit_hamming_ops) WITH (m = 64, ef_construction = 256);

CREATE INDEX CONCURRENTLY imagehashes_p0_perceptualhash_idx ON Hashes_p0 USING hnsw (perceptualHash bit_hamming_ops) WITH (m = 64, ef_construction = 256);
ALTER INDEX ix_perceptual_hash ATTACH PARTITION imagehashes_p0_perceptualhash_idx;

CREATE INDEX CONCURRENTLY imagehashes_p1_perceptualhash_idx ON Hashes_p1 USING hnsw (perceptualHash bit_hamming_ops) WITH (m = 64, ef_construction = 256);
ALTER INDEX ix_perceptual_hash ATTACH PARTITION imagehashes_p1_perceptualhash_idx;
...
``` 

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


end of thread, other threads:[~2026-01-22 15:38 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-01-21 19:02 [pgvector/pgvector] issue #949: HNSW partitions and parameters "brycechesternewman (@brycechesternewman)" <noreply+brycechesternewman@github.com>
2026-01-22 00:38 ` "ankane (@ankane)" <noreply+ankane@github.com>
2026-01-22 00:38 ` "ankane (@ankane)" <noreply+ankane@github.com>
2026-01-22 15:38 ` "brycechesternewman (@brycechesternewman)" <noreply+brycechesternewman@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