Reputation: 1248
Can someone explain in simple terms what is the static column in Cassandra, and its use? I came across this link Static column, but wasn't able to understand it much.
Upvotes: 3
Views: 594
Reputation: 87109
Static column is a way to associate data with the whole partition, so it will be shared between all rows inside that partition. There are legitimate cases, when all rows need to have the same data, and when data is updated, we won't need to update every row.
One example that comes in mind is e-commerce. For example, you're selling something, and you're selling in different countries with different currency & different prices. But some things are common between them, like, description, sizes, etc. In this case we can model it as following:
create table articles (
sku text,
description text static,
country text,
currency text,
price decimal,
primary key (sku, country)
);
in this case, when you do select * from articles where sku = ... and country = ...
then you get description anyway, and you can update description only with update articles set description = '...' where sku = ...
, and next select will pull updated description.
Also, static columns may exist in partition without any rows. One of the use cases that I've seen is collection of the aggregated information, where detailed data were stored as individual rows with some TTL, and there was a job that aggregated data into static column, so when rows are expired, then this partition still stays only with aggregated data.
Upvotes: 5