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 3 July 2026

  • 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.

  • https://planetscale.com/blog/sharding-vs-partitioning-whats-the-difference
  • https://blog.devgenius.io/partitioning-vs-sharding-a-practical-guide-to-scaling-beyond-one-machine-f1b9d92150fe
  • https://www.pingcap.com/article/sharding-vs-partitioning-a-detailed-comparison/
All SQL interview questions