pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] issue #796: Horizontal scalability (with citus)
7+ messages / 3 participants
[nested] [flat]

* [pgvector/pgvector] issue #796: Horizontal scalability (with citus)
@ 2025-03-07 14:12 "amano-kenji (@amano-kenji)" <noreply+amano-kenji@github.com>
  0 siblings, 0 replies; 7+ messages in thread

From: amano-kenji (@amano-kenji) @ 2025-03-07 14:12 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

There are two issues I can think of. If these two sharding issues are gone, I think postgres would be the best database for me.

## recall rate across shards

https://github.com/pgvector/pgvector/pull/129#issuecomment-1657706476 says citus reduces recall rate.

I guess citus reduces recall rate because vector space is split between shards, and postgres doesn't recognize all shards as one vector space.

## being forced to query all shards for vector search.

Since embeddings are split across shards, I can't know which shards to query. Thus, I have to query all shards. Querying all shards for every vector search is bad for performance.

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

* Re: [pgvector/pgvector] issue #796: Horizontal scalability (with citus)
@ 2025-03-07 14:51 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: jkatz (@jkatz) @ 2025-03-07 14:51 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

This is something you'll have to work with the Citus maintainers on. I've [lightly discussed distributed vector search workloads](https://jkatz05.com/post/postgres/distributed-pgvector/) and when it makes sense to do this.

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

* Re: [pgvector/pgvector] issue #796: Horizontal scalability (with citus)
@ 2025-03-07 15:53 ` "amano-kenji (@amano-kenji)" <noreply+amano-kenji@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: amano-kenji (@amano-kenji) @ 2025-03-07 15:53 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Your test results say shards increase recall and decrease query throughput? Anyway, we still don't know how to avoid querying all or many nodes for vector search. I don't know whether it's okay to query all or many nodes for vector search.

So, your conclusion is that recall rate isn't a problem for sharding?

I think I will look into how milvus tackles distributed vector database problem.

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

* Re: [pgvector/pgvector] issue #796: Horizontal scalability (with citus)
@ 2025-03-07 17:08 ` "ankane (@ankane)" <noreply+ankane@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: ankane (@ankane) @ 2025-03-07 17:08 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi @amano-kenji, sharding with same options will increase recall, not decrease it (please test this yourself before creating an issue for it).

If you need to search the entire table, it'll need to search all shards. Otherwise, you can specify a distribution column and Citus will only query a single shard (see [this example](https://github.com/pgvector/pgvector-python/blob/master/examples/citus/example.py) - add `category_id` to query a single shard).

Edit: You could also assign vectors to shards using a similar approach to IVFFlat and only search the closest shards to the query vector (this could be implemented at the application level on top of pgvector).

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

* Re: [pgvector/pgvector] issue #796: Horizontal scalability (with citus)
@ 2025-03-07 17:08 ` "ankane (@ankane)" <noreply+ankane@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: ankane (@ankane) @ 2025-03-07 17:08 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ankane closed this.

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

* Re: [pgvector/pgvector] issue #796: Horizontal scalability (with citus)
@ 2025-03-08 01:39 ` "amano-kenji (@amano-kenji)" <noreply+amano-kenji@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: amano-kenji (@amano-kenji) @ 2025-03-08 01:39 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@jkatz I just read your article fully. Can I easily push down session parameters and implement async execution across “merge append” nodes without any upstream fix?

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

* Re: [pgvector/pgvector] issue #796: Horizontal scalability (with citus)
@ 2025-03-08 02:26 ` "amano-kenji (@amano-kenji)" <noreply+amano-kenji@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: amano-kenji (@amano-kenji) @ 2025-03-08 02:26 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Upon further inspection, it seems citus will parallelize node operations before aggregating the results at the coordinator. I suspect citus is going to be faster than postgres_fdw, but I haven't really tested.

Update: citus doesn't support custom sharding methods. postgres_fdw doesn't support parallel MergeAppend plans. I guess you are forced to roll your own sharding solution at the application level. If your application implements its own PostgreSQL pgvector sharding mechanism, it will bypass citus, postgres_fdw, and other existing horizontal scaling solutions.

Update 2: I can calculate a shard key from a vector embedding and other information. Then, I can put the shard key in a table column. Citus can use this. I guess I can calculate a few relevant shards for a vector embedding. By narrowing down the number of shards you deal with for each vector embedding, you can reduce the load on postgres.

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


end of thread, other threads:[~2025-03-08 02:26 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-03-07 14:12 [pgvector/pgvector] issue #796: Horizontal scalability (with citus) "amano-kenji (@amano-kenji)" <noreply+amano-kenji@github.com>
2025-03-07 14:51 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2025-03-07 15:53 ` "amano-kenji (@amano-kenji)" <noreply+amano-kenji@github.com>
2025-03-07 17:08 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-03-07 17:08 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-03-08 01:39 ` "amano-kenji (@amano-kenji)" <noreply+amano-kenji@github.com>
2025-03-08 02:26 ` "amano-kenji (@amano-kenji)" <noreply+amano-kenji@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