Zenaique

Sharding a vector index that does not fit on one node, how is it typically done, and what's the query time cost?

Short answer·Medium·4.0 · 0·~3 min·Asked atPineconeQdrantSpotify·Relevant atDatabricksTurbopuffer
Attempt it

Describe how managed vector databases shard an index that exceeds single node RAM, and explain the query time consequences for QPS and p99 latency.

Free · 2 AI evals / day
TL;DR

Random or hash based shard-by-id. Each shard runs its own ANN index. Queries scatter gather to all shards and merge top-K.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine your library is too big for one room. So you split the books randomly into ten rooms, with one librarian per room. When someone asks 'find me books like this one', the question is asked to all ten librarians at once. Each librarian searches their own room and brings back their best 10 matches. Then you compare the ten lists and keep the best overall. This is fast when all librarians answer quickly. But on a busy day, if even one librarian is slow, your customer has to wait for them. Adding more rooms means more answers per minute (throughput), but it does not make any single answer faster, and the chance that at least one room is slow goes up with each new room.

Key concepts

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Sharding is what makes vector databases scale past one node. The mechanism is conceptually simple (split the corpus across nodes, each node runs its own index, fan out queries) but the consequences are subtle. The biggest surprise for engineers used to relational sharding: vector-DB sharding does not improve per query latency, it can make it worse, and the fix is not 'add more shards'.

The question is testing whether a candidate understands the scatter gather model and the tail at scale problem it inherits, and whether they know the mitigations that 2026 production systems actually use.

Random hash sharding: the boring default that wins

Every billion scale managed vector database in 2026 uses some form of random or hash based sharding by vector ID. The recipe is: compute hash(vector_id) mod N_shards, that shard owns the vector. The shard then builds its own ANN index (HNSW or IVF-PQ) over its slice.

This looks boring next to alternatives. Why not cluster based sharding, where each shard owns one k-means cluster and queries only touch the shards near them? Or per-tenant sharding, where each tenant gets dedicated shards? Both have been tried and both lose to random sharding in production.

Cluster-based sharding loses on skew. Real corpora are anisotropic: some clusters have 10x the documents of others. Some queries land in hot clusters; their shards become bottlenecks while the cold-cluster shards sit idle. Worse, popular query patterns can hit the same shards every minute, while other shards see no traffic. Random sharding sidesteps all of this with the law of large numbers: every shard sees roughly the same load, every query hits every shard.

Per-tenant sharding can work for multi tenant workloads but introduces a different problem: tenants with little data leave shards underutilized, while large tenants need to be re-sharded internally anyway. The hybrid pattern that's emerged (Pinecone namespaces, Milvus partition keys, Weaviate multi-tenancy mode) is random sharding plus a routing key that lets multi tenant queries target a subset.

The scatter gather query path
QPS scales, but p99 does not (and often gets worse)
Mitigations that actually work in production
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
PropertyWhat sharding gives youWhat sharding does not give you
QPSLinear scaling with shard countSame per query latency
Memory ceilingIndex larger than one node's RAMMemory efficiency per vector
AvailabilityReplicas handle shard lossEventual-consistency guarantees by default
p99 latencyWorse with more shards (tail at scale)Lower per query latency
Tenant isolationShard-affine routing if partition keys are usedFree isolation; you must design it in

Real products, models, and research that use this idea.

  • Pinecone's pod model shards the corpus across pods of fixed RAM; serverless tier shards across stateless query nodes pulling from object storage. Both use random shard assignment with hedged reads.
  • Milvus separates the architecture into data, index, query, and coordinator nodes. Sharding is at the segment level; partition keys allow shard affine routing for multi tenant workloads.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QWhy is the maximum of N percentile higher than the individual shards' percentile?
A

Order statistics. The max of N independent random variables has a distribution shifted to the right of any individual. For exponential distributions, the expected max grows as ln N. Concretely, p99 of max ~ p99 of individual * (1 + ln N / large constant).

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Believing that adding shards reduces per query latency. It reduces per shard work but not the wall clock time, because the query waits for the slowest shard.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Random / hash sharding by vector ID as the default scheme

  • Each shard is an independent ANN index (HNSW or IVF-PQ)

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
HNSW vs IVF, when…
Flashcard·Medium