Apache Cassandra

Wide Rows & Time-Series Data Modeling

Learn techniques for modeling time-series data in Cassandra using wide partitions and time-bucketing to avoid unbounded partition growth.

Cassandra is a popular choice for time-series workloads (IoT sensors, application metrics, event logs) because clustering columns naturally support storing many rows per partition sorted by time — a pattern often called a wide row or wide partition. All events for a given entity (e.g., a device) can be written to the same partition and retrieved together in a single efficient read, sorted by timestamp.

Instead of stuffing every year's worth of a person's mail into one infinitely growing mailbox, you switch to a new labeled mailbox each month — retrieving one month's mail is still a single simple lookup, and old mailboxes can be discarded wholesale once they're no longer needed.

Key Concepts

1
However, naively using a single partition key like device_id for years of continuous high-frequency data leads to unbounded partition growth, eventually creating an oversized partition that degrades read/write performance, increases compaction cost, and can even risk hitting hard limits on partition size.
unbounded partition growthdevice_id
2
The standard solution is time bucketing: incorporating a time component (like year-month or year-month-day) into the partition key alongside the natural entity ID, so that each partition only covers a bounded time window. This keeps individual partitions manageably sized while still allowing efficient range queries within a bucket, and queries spanning multiple buckets can be issued as parallel per-bucket queries at the application layer.
time bucketing
3
This pattern pairs naturally with TimeWindowCompactionStrategy and TTLs, since entire time-bucketed partitions (and their underlying SSTables) tend to age out and expire together.
TimeWindowCompactionStrategy