Explain the difference between horizontal partitioning within one DB instance and sharding across multiple instances. When does an engineer need to move from one to the other?
Last updated
Horizontal partitioning splits a table's rows by key within one instance. It works transparently and enables partition pruning and easy archival, but stays bounded by one machine.
Sharding spreads data across separate DB servers to scale writes and storage. The cost is hard cross-shard joins and transactions, plus routing by shard key.
Move to sharding only when one instance can't handle write throughput or data volume after partitioning, vertical scaling, indexing, caching, and replicas.