AlgoViz

Introduction to data partitioning

easy 25 min

Data partitioning splits one large set of data into smaller parts by a rule, so that each part is easier to store, search and maintain.

Where it shows up

The same pattern appears across everyday software.

  • Notion

    Split its block data by workspace id into 480 logical shards on 32 physical PostgreSQL databases. People usually work inside one workspace, so most cross-shard joins are avoided.

  • Figma

    First moved groups of related tables to their own databases, then sharded rows. Related tables that share a key are kept together in groups they call colos.

  • GitHub

    Grouped tables into schema domains, checked in the application that nothing joined across them, and then moved groups to other clusters, partly with Vitess.

  • PostgreSQL time tables

    Orders, events and logs are often range partitioned by month. Dropping an old month avoids a huge delete and the clean-up after it.

  • Elasticsearch

    An index is split into primary shards. A document goes to the shard given by a hash of its routing value, with the number of primary shards in the formula.

  • Discord

    Described storing messages in Cassandra partitions keyed by channel and a time bucket of about 10 days, so that a busy channel does not become one endless partition.