openskills.info
Course Preview

Database Partitioning and Sharding Strategies

Database partitioning divides one logical data set into smaller physical pieces. Sharding places those pieces across database servers so storage and request load can grow beyond one machine.

itDatabases and data storage

Database Partitioning and Sharding Strategies

Database partitioning divides one logical data set into smaller physical pieces. A partitioning rule maps every row or item to one piece. The database can then route writes to the right piece and avoid unrelated pieces when a query contains compatible key conditions.

Sharding is horizontal partitioning across database servers. Each shard owns a subset of the rows, while the application usually treats the collection or table as one logical data set. A routing layer, client library, coordinator, or application function determines which shard handles an operation.

These terms overlap, but they are not interchangeable in every product. A PostgreSQL table can have many partitions on one server. A MongoDB sharded collection distributes chunks across multiple shards. A distributed database can divide its keyspace into ranges or tablets and move them between nodes automatically. Always check whether a product uses partition for a logical key range, a physical storage unit, or both.

The data path

A partitioned request follows a decision path:

  1. The application sends a read or write with key values and predicates.
  2. A router evaluates those values against the partitioning function or partition bounds.
  3. The router targets one partition when it can prove the location. It targets several partitions when the predicate spans boundaries.
  4. Each target executes its local portion of the operation.
  5. A coordinator combines partial results when more than one partition participates.

Targeted operations keep routing and execution local. MongoDB calls an operation without usable shard-key constraints a scatter-gather operation because the router broadcasts it to multiple shards. Distributed joins, aggregates, and transactions can also cross shard boundaries. They require network messages, coordination, and sometimes data movement, so the partition key is also an application-architecture decision.

Partitioning methods

Continue the course

This section is part of the paid course.

See pricing to subscribe, or log in if you already have access.

Where this skill leads

Relevant careers

See how this topic contributes to broader role-level skill maps.

Sources