In system design, the terms Partitioning, Replication, and Sharding are frequently confused, even though they solve different bottlenecks, as highlighted in the PostgreSQL High Availability documentation.
Each pattern owns its own front:
- Partitioning: splits a table into sections within a single host (for example, by date). It speeds up queries via partition pruning and lets you drop archives with
DROP TABLEinstead of a heavyDELETE. Storage volume is still capped by one server's disk. - Replication: creates identical copies of a database on other servers via WAL streaming. It guarantees failover resilience if the primary goes down and distributes reads (
SELECT), yet it does not scale writes (INSERT/UPDATE). - Sharding: distributes slices of a table across independent servers by a shard key. It saves you when terabytes of writes outgrow a single machine, though it complicates transactions and makes cross-shard JOINs very expensive.
As we examined in partitioning vs. sharding, architecture always starts with partitions and replicas, turning to sharding only when a server hits its physical limit.
