Menu

1 / 5

Partitioning vs Sharding: Splitting Tables Inside One Database or Across Many

DEV Community: backend·Abdeldjalil Chougui·3 days ago
#W80qE9Nn
#devtobackend#devto#dev#shard#partition
Long article (1272 words) — no AI summary yet.
Reading 0:00
15s threshold

Your events table started small. Two years later it holds hundreds of millions of rows, the nightly cleanup job runs for hours, the indexes no longer fit in memory, and every query that touches "last week" still has to deal with an index that covers everything since launch.

Two words come up when people talk about fixing this: partitioning and sharding. They are often used as if they meant the same thing. They do not. Both split data into pieces, but they split it in different places, and they solve different problems.

Partitioning splits one logical table into smaller physical pieces inside one database server .

Sharding splits the data across several database servers , each holding part of the rows.

Get this distinction right and you will usually find that you need the first long before you need the second.

Partitioning: one server, many pieces

With partitioning, the application still sees a single table.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.