Skip to main content

Command Palette

Search for a command to run...

Sharding vs Partitioning

Learn the difference between logical table partitioning and distributed database sharding.

Updated
โ€ข1 min readโ€ขView as Markdown

Database scaling uses splitting strategies to handle massive datasets. While partitioning divides data within a single server, sharding distributes it across multiple nodes.

๐Ÿ“Š Key Differences

Partitioning (Single Node)

Splits a large table logically into smaller tables on the same database instance.

  • Example: Partitioning a sales table by month (sales_2024_01, sales_2024_02).
  • Purpose: Speeds up queries and maintenance (like dropping old months) on a single disk.

Sharding (Multi-Node / Shared-Nothing)

Distributes table shards across entirely separate server nodes with independent CPU, RAM, and Disk.

  • Purpose: Solves hardware scale limits by distributing the write and storage load horizontally.
                   [ Users Table ]
                 /                 \
     Shard A (Nodes A-M)       Shard B (Nodes N-Z)
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚  Database Srv 1 โ”‚       โ”‚  Database Srv 2 โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜