1 min read

Partitioning and Sharding

Partitioning

Partitioning refers to the process of dividing a large table(data) into smaller, more manageable segments or partitions in the same instance.

Sharding

Sharding involves distributing data across multiple database systems or instances. The data may be identical or distinct, depending on the specific use case. Sharding is often used to distribute data horizontally.

Sharding and partitioning often work in tandem and can be combined in various ways:

  1. Neither sharded nor partitioned: This occurs when there is only one database server without any division of data.
  2. Partitioned but not sharded: Data is split into multiple partitions, but they are on the same database instance (server).
  3. Sharded but not partitioned: In this scenario, there is only one partition, and the data has been replicated to other servers. This results in multiple servers (shards) containing the same data, which is how read replicas are created.
  4. Both sharded and partitioned: Data is divided into multiple partitions, with each partition residing on its own server (shard). This configuration can handle large write loads effectively. This is also horizontal sharding.