# Database Sharding

> The rows of a big database, split across many servers. Each holds a part.

**Field:** Software Development  
**Category:** Databases  
**Also known as:** Sharding, Shard, Horizontal Partitioning

## Think of it like

Think of it like splitting a class list across three teachers by surname. A to H goes to one, and so on.

## Definition

Sharding splits the rows of one big database across several servers. Each server, called a shard, holds only part of the data. A shard key, like the user id, decides which shard each row lives on. This lets a database grow past what one server can hold or handle. It adds a lot of work, so most teams shard only when nothing else is enough.

## Example

A chat app with 500 million users puts users 1 to 100 million on shard one, and so on. Each server only carries a fifth of the load.

## Why it matters

There is a limit to how big one server can get. Sharding is how the largest apps go past it.

## Common mistake

Sharding too early. It makes joins, reports and changes much harder, and a bigger server or a replica is often enough.

## Three principles

- **Split the rows.** Each shard holds a part.
- **A shard key.** It decides where each row goes.
- **Last resort.** Try bigger servers and replicas first.

## Related terms

- [Database Replication](https://learn.benibix.com/term/development/database-replication)
- [Read Replica](https://learn.benibix.com/term/development/read-replica)
- [Database](https://learn.benibix.com/term/development/database)
- [Primary Key](https://learn.benibix.com/term/development/primary-key)

## Told apart from

- [Replication vs Sharding](https://learn.benibix.com/compare/replication-vs-sharding): Replication puts a full copy of the data on each server. Sharding splits the rows, so each server holds just a part.
- [Data Partitioning vs Database Sharding](https://learn.benibix.com/compare/data-partitioning-vs-sharding): People think partitioning and sharding are the same thing. Both split data into parts. One splits a table into parts inside one system, often by date, so queries can skip parts. The other spreads rows over many database servers, so each server takes part of the load.

---

Source: https://learn.benibix.com/term/development/sharding
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
