Home / Companies / PlanetScale / Blog / Post Details
Content Deep Dive

Sharding strategies: directory-based, range-based, and hash-based

Blog post from PlanetScale

Post Details
Company
Date Published
Author
Holly Guevara
Word Count
1,168
Language
English
Hacker News Points
-
Summary

Sharding strategies can be categorized into three types: directory-based, range-based, and hash-based. Directory-based sharding involves mapping data to shards using a lookup table, which is useful for specific criteria but may result in uneven data distribution and an extra query step. Range-based sharding splits up the shard mapping based on a range of values, which can lead to overloaded shards but allows for easy resharding operations. Hash-based sharding distributes data evenly across shards using a hash function, minimizing human guesswork and offering easier resharding options. PlanetScale typically recommends hash-based sharding as the default option due to its simplicity and effectiveness in maintaining an even distribution of data.