skip to content

Why does a vector store with randomly placed shards send every query to every shard, and which placements let a query skip shards?

level: middleimportance: must knowfreq 50%

answer

  1. where could the neighbours be?
  2. placement key the query carries
  3. exact skip versus approximate skip
  4. skew is the price of routing

basics

~20 s

Random or hashed placement can put any vector on any shard, so a query's neighbours could be anywhere and every shard is searched. Placing by tenant key skips shards exactly; placing by vector cluster skips them approximately, risking recall.

solid answer

~50 s

With random or hash placement, where a vector lands has nothing to do with where it sits in vector space, so the router cannot know which shards hold a query's nearest neighbours and must ask all of them. That is safe for recall but every query pays one search per shard, and the bill grows with the shard count. A query can skip shards only when placement follows something the query already knows. Placing by a **tenant key** (or any key every query carries) sends a query only to that tenant's shards with no recall loss. Placing by **vector cluster** sends a query to the shards whose centroids are nearest, which cuts fan-out but can miss neighbours just across a boundary. Both trade even load for routing: big tenants and dense clusters make hot, oversized shards.

go deeper

for a junior

Recall that a hash of a record ID says nothing about where its vector sits, so the router must ask every shard.

for a middle

Explain fan-out cost as shard searches per query, and contrast exact skipping by tenant key with approximate skipping by vector cluster.

for a senior

Pick the placement from the query mix: what fraction of queries carry the key, how skewed the key is, and what a hot shard costs. Name the re-routing cost before committing.

for a principal

Treat placement as a long-lived contract: once tenants or clusters own shards, changing it means moving and rebuilding indexes, so set it with growth and skew in view.

## Why random placement fans out A vector store splits a collection into **shards**, each with its own approximate nearest-neighbour index. Something decides which shard each vector goes to. The simplest choice is **random** or **hash** placement: hash the record's ID and take it modulo the shard count, or assign round-robin. Hash placement balances load beautifully, and that is its whole point. But the hash of an ID carries no information about the vector's **position** in embedding space. Two near-identical vectors are as likely to land on different shards as on the same one. So when a query arrives, the router has no way to tell which shard holds its nearest neighbours: any of them might. The only correct plan is to send the query to **every** shard, take each shard's best matches, and combine them (the combining step is covered with query fan-out over sharded indexes). This costs no recall: every shard is searched. What it costs is work. ## What fan-out costs as the cluster grows Under random placement, the number of index searches per query equals the shard count: - A scenario's 32 shards serving 1,000 queries per second run **32,000 shard searches per second**. - Growing to 64 shards for capacity doubles that to 64,000, even though the query rate did not change. - Each shard search is smaller, but graph search cost falls only slowly with graph size, so total work rises. That is why "add shards" is a capacity fix, not a throughput fix, and why a store with hundreds of small shards can be slower than one with a few large ones. ## Placements that let a query skip shards A router can skip a shard only if placement followed something the query already knows. Two families of placement do that: | Placement | How a query is routed | Recall | Main cost | |---|---|---|---| | Random or hash | To every shard | Full: nothing is skipped | Fan-out grows with shard count | | Tenant key (or any key every query carries) | Only to that key's shards | Full, for queries scoped to one key | Skew: big keys make big, hot shards | | Vector cluster (nearest centroid) | To the few shards whose centroids are nearest | Approximate: neighbours across a boundary are missed | Uneven shard sizes, drift, re-clustering | | Tenant key, then random within large tenants | To that tenant's shards only | Full within the tenant | Large tenants still fan out internally | **Tenant-key placement** is exact: if every query is scoped to one tenant and that tenant's vectors live only on its shards, the other shards cannot hold an answer, so skipping them loses nothing. It works for any key that every query is guaranteed to carry, such as a region or a product line. **Cluster placement** groups vectors by similarity, typically by training centroids with k-means and placing each vector on the shard of its nearest centroid. A query visits only the shards whose centroids are closest. That cuts fan-out sharply, but the true nearest neighbour can sit just across a cluster boundary, on a shard the router skipped. How much recall that risks, and how to bound it, is its own design question. ## What routing costs you Every placement that enables skipping gives up the even load that random placement provides: 1. **Skew.** One tenant with a hundred times the data of the median fills its shard while others sit half-empty. 2. **Hot shards.** Popular tenants or popular regions of vector space concentrate query load on a few nodes. 3. **Rigidity.** Re-routing later (re-clustering, or moving a tenant) means moving vectors between shards, and that usually means rebuilding the affected indexes. 4. **Queries without the key.** A global search across all tenants, or an administrative query, still fans out to everything. ## A filter is not a placement A metadata filter on tenant ID does not, by itself, let a query skip shards. If vectors were placed at random, every shard holds some of every tenant, so every shard still has to run the filtered search. Shard skipping comes only from **placement**, not from the predicate. The filter's own cost inside each shard is covered with metadata filtering. ## Common mistakes - Believing any metadata filter lets the router skip shards, whatever the placement. - Believing random placement loses recall: it searches everything, so it loses only efficiency. - Treating cluster routing as exact, the way tenant routing is.

  • If every query carries a tenant ID, is tenant-key placement always better than random placement?
    Not always. It skips shards exactly, but it gives up even load: a tenant much larger than the rest fills or overheats its shard, and that tenant's own data may need several shards that its queries fan out across. Queries that span tenants still visit every shard. It wins when tenants are small relative to a shard and most queries stay inside one.
  • Can a vector store with random placement skip shards using per-shard summaries instead of a placement key?
    Sometimes, for exact-match fields. If each shard records which values of a field it holds, a router can skip shards that hold none of the requested value, which helps when a value happens to be concentrated. For the vectors themselves, a random shard's summary covers most of the space, so it rarely lets a similarity query skip anything.

  • Any metadata filter lets the router skip shards, whatever the placement.
  • Random placement loses recall because similar vectors are spread across shards.
  • Routing to the nearest cluster centroids is as exact as routing by tenant.
  • Fan-out cost stays flat as shards are added.
  • Hash placement by record ID groups similar vectors together.