SQL vs NoSQL: How to Choose
SQL vs NoSQL explained: data models, consistency, scaling, query flexibility and when to use relational, document, key-value, wide-column or graph databases.
What database sharding is, when you need it, how to choose a shard key, range vs hash vs directory sharding, and the operational pain points to plan for.

Sharding (horizontal partitioning) splits a large dataset across multiple database servers, each holding a subset of the rows. It’s how systems scale writes and storage beyond what a single machine can handle, and it’s one of the most consequential architectural decisions you can make.
Sharding adds real complexity. Try these first:
Shard when a single primary can’t handle your write volume or data size even after these steps.
| Strategy | How it works | Pros | Cons |
|---|---|---|---|
| Range | Rows assigned by key ranges (A–F, G–M…) | Efficient range queries | Hot spots when keys cluster |
| Hash | A hash of the key picks the shard | Even distribution | Range queries hit every shard |
| Directory | A lookup service maps keys to shards | Flexible, easy rebalancing | Extra lookup; directory must be highly available |
| Geographic | Rows placed by region | Data locality, compliance | Uneven regional load |
Hash sharding with consistent hashing is a common way to add shards without moving most of the data.
A good shard key:
Bad choices include timestamps (all new writes hit one shard) and low-cardinality fields like country.
Many teams use databases or proxies with built-in sharding rather than building it themselves. Whatever you choose, design the shard key around your access patterns from the start, because changing it later is painful. Our SQL vs NoSQL guide covers which databases shard automatically.
Partitioning is the general idea of splitting data; sharding usually means partitioning across multiple servers.
Replication copies the same data to multiple servers for availability and read scale; sharding splits different data across servers for write and storage scale. Large systems use both.
Yes. It’s common, though it limits joins and transactions across shards.
Every article is edited by a human and checked against our editorial policy. Spotted a mistake? Tell us.
SQL vs NoSQL explained: data models, consistency, scaling, query flexibility and when to use relational, document, key-value, wide-column or graph databases.
How B-tree and LSM-tree storage engines work, why one favours reads and the other writes, write and read amplification, compaction and which databases use each.
How database indexes work: B-tree and other types, composite and covering indexes, why queries ignore indexes, the write cost and checking with EXPLAIN.