Mandroid
Mandroid

Reputation: 7468

Wide partition pattern in Cassandra

What is 'wide partition pattern' in Cassandra? In book 'Defiinitive Cassandra' it seems its a recommended thing, but in some online articles I see its something to be avoided.

So what actually it is and it is preferrable or not?

Upvotes: 1

Views: 1425

Answers (2)

Alan
Alan

Reputation: 634

wide partition refers a partition which contains many cells/values (number_of_cells = column * row)

The commonly used time series design pattern is a great example for wide partition table design: You use the date bucket as the partition key, each bucket will contain all timestamps for the date range defined by that bucket.

This model illustrates why it's called "wide" partition

enter image description here

another dynamodb example, the idea is the same (sort key in dynamodb is the same as clustering key in cassandra) enter image description here

Upvotes: 0

Manish Khandelwal
Manish Khandelwal

Reputation: 2310

Partition in Cassandra represent grouping of similar kind of rows. In Cassandra it is recommended to model your data such that you should have similar kind of rows fall in same partition. This is called wide partition pattern.

Searching in Cassandra is super fast using partition key. So wide partition pattern is recommened. But with this recommendation comes a warning that your wide partitions should not become too large.

The reason for warning (avoiding large partitions) is that searching becomes too slow as search within partition is slow. Also it puts lot of pressure on heap.

For better understanding, would recommend reading this blog https://thelastpickle.com/blog/2019/01/11/wide-partitions-cassandra-3-11.html

Upvotes: 1

Related Questions