Sharding Pgvector
Published on: 2025-05-29 06:10:30
Sharding pgvector
Mar 25th, 2025
Lev Kokotov
If you find yourself working with embeddings, you’ve shopped around for a vector database. pgvector is a great option if you’re using Postgres already. Once you reach a certain scale (about a million arrays), building indices starts taking a long time. Some workarounds, like parallel workers, help, but you still need to fit the whole graph in memory.
The solution to lots of data is more compute, so we sharded pgvector. In this context, we’re specifically talking about sharding a vector index. Splitting tables between machines is easier. Our goal is to have fast and good recall: we want to quickly find matches when we search for them.
A bit of background
pgvector has two types of indexes: HNSW and IVFFlat. They are different ways to organize vectors in multi-dimensional space. HNSW builds a multi-layer graph that can be searched quickly, in O(log(n)) time. The trade-off is it takes a long time to build.
IVFFlat splits the vector space
... Read full article.