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 | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Intro
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:
- The application sends a read or write with key values and predicates.
- A router evaluates those values against the partitioning function or partition bounds.
- The router targets one partition when it can prove the location. It targets several partitions when the predicate spans boundaries.
- Each target executes its local portion of the operation.
- 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
- https://www.postgresql.org/docs/current/ddl-partitioning.html
Supports
- Partition definition, range, list, and hash methods, virtual parent storage, tuple routing, subpartitioning, and pruning
- Attach, detach, drop, index, planning-time, partition-count, and memory tradeoffs
- https://dev.mysql.com/doc/refman/8.4/en/partitioning-pruning.html
Supports
- Partition pruning as excluding partitions that cannot satisfy compatible predicates
- https://www.mongodb.com/docs/manual/sharding/index.html
Supports
- Chunks, inclusive-lower and exclusive-upper ranges, mongos routing, targeted operations, balancing, and cross-server horizontal scaling
- https://www.mongodb.com/docs/manual/core/sharding-choose-a-shard-key/
Supports
- Shard-key cardinality, frequency, monotonicity, query alignment, and scatter-gather consequences
- https://www.mongodb.com/docs/manual/core/sharding-troubleshooting-shard-keys/
Supports
- Hot shards, jumbo chunks, uneven distribution, and scatter-gather diagnosis
- https://vitess.io/docs/25.0/overview/whatisvitess/
Supports
- VTGate, VTTablet, topology service, MySQL shard groups, replication, routing, and managed lifecycle
- https://vitess.io/docs/faq/advanced-configuration/vschema/how-do-you-select-your-sharding-key-for-vitess/
Supports
- Query frequency, key uniqueness, high cardinality, and colocation criteria for a primary Vindex
- https://vitess.io/docs/24.0/user-guides/configuration-advanced/resharding/
Supports
- Online shard splitting, target copy and catch-up, verification, and serving switch concepts
- https://vitess.io/docs/archive/11.0/overview/history/
Supports
- Vitess creation at YouTube in 2010, routing removal from application code, CNCF incubation in 2018, and graduation in 2019
- https://docs.citusdata.com/en/stable/get_started/concepts.html
Supports
- Distribution columns, algorithmic row-to-shard mapping, worker shards, and logical distributed tables
- https://docs.citusdata.com/en/v7.0/sharding/colocation.html
Supports
- Shared distribution keys, colocated hash ranges, shard-local joins, transactions, and foreign keys
- https://www.amazon.science/publications/dynamo-amazons-highly-available-key-value-store
Supports
- 2007 publication, consistent-hash partitioning, replication, availability, versioning, and conflict tradeoffs
- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.Partitions.html
Supports
- Managed physical partitions and hashing of partition-key values
- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-partition-key-design.html
Supports
- Uniform activity goals and write sharding for hot key patterns
- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/burst-adaptive-capacity.html
Supports
- Hot-partition behavior, burst capacity, and adaptive capacity
- https://research.google/pubs/bigtable-a-distributed-storage-system-for-structured-data/
Supports
- 2006 publication and large-scale structured storage across commodity servers
- https://research.google/pubs/spanner-googles-globally-distributed-database-2/
Supports
- 2012 publication, global distribution, synchronous replication, transactions, and external consistency
- https://docs.cloud.google.com/spanner/docs/schema-and-data-model
Supports
- Primary-key ordering, contiguous splits, automatic split changes, colocation, and hotspot risks from monotonic keys
- https://www.cockroachlabs.com/docs/stable/architecture/overview/
Supports
- Contiguous key ranges, replicas, leaseholders, consensus, routing, and automatic distribution
- https://www.cockroachlabs.com/blog/cockroachdb-1-0-release/
Supports
- May 2017 production release and distributed SQL over ranges and replicated transactions
- https://docs.yugabyte.com/stable/architecture/docdb-sharding/
Supports
- Tablets, range and hash sharding, automatic splitting, and cluster balancing
- https://docs.yugabyte.com/stable/architecture/docdb-sharding/tablet-splitting/
Supports
- Presplitting, manual splitting, automatic splitting, and online resharding
- https://cassandra.apache.org/_/cassandra-basics.html
Supports
- Partition keys, token ranges, node distribution, replicas, coordinators, and tunable consistency levels
- https://aerospike.com/docs/database/learn/architecture/clustering/data-distribution
Supports
- Logical partition hashing, peer-node placement, replicas, client routing, and automatic rebalancing
- https://rocksdb.org/
Supports
- RocksDB as an embedded persistent key-value store with ordered keys
- https://www.postgresql.org/docs/10/release-10.html
Supports
- October 2017 PostgreSQL 10 release and declarative table partitioning milestone
- https://github.com/sindresorhus/awesome
Supports
- Discovery path to the curated Awesome Database list
- https://github.com/numetriclabz/awesome-db
Supports
- Discovery of Aerospike, MongoDB, RocksDB, Cassandra, and Citus-related ecosystem material
- https://www.mongodb.com/atlas
Supports
- MongoDB Atlas as a managed MongoDB service in the sharding market
- https://aws.amazon.com/dynamodb/
Supports
- DynamoDB as a managed distributed key-value and document database
- https://cloud.google.com/spanner
Supports
- Spanner as a managed distributed SQL database
- https://www.cockroachlabs.com/product/cockroachdb/
Supports
- CockroachDB as a distributed SQL product
- https://www.yugabyte.com/yugabytedb/
Supports
- YugabyteDB as a distributed SQL product
- https://www.pingcap.com/tidb/
Supports
- TiDB as a distributed SQL product with separated SQL and key-range storage layers
- https://vitess.io/
Supports
- Vitess as an open-source MySQL sharding system
- https://www.citusdata.com/
Supports
- Citus as an open-source PostgreSQL distribution extension
- https://www.oracle.com/database/distributed-database/
Supports
- Oracle's commercial distributed database and sharding offering
