Junior SQL

What is database sharding and when do you use it?

Sharding is the process of breaking a large database into smaller, more manageable pieces

(shards), each of which is stored on a different server.

  • When to use it:
  • When a single database server can no longer handle the volume of data or

queries.

  • When scaling vertically (increasing server resources) is no longer

cost-effective or possible.

  • How it works:
  • The data is divided based on a specific shard key (e.g., user ID, geographic

region, etc.).

  • Each shard contains a subset of the data and is stored on a separate server

or cluster.

Example: In an e-commerce platform, you could shard user data based on geographic

region. Users from the US might be stored in one shard, while users from Europe are stored

in another.

More from SQL Server Tutorial

All questions for this course