Static column in Cassandra

大憨熊 提交于 2020-05-28 04:25:05

问题


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.

Thanks


回答1:


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.



来源:https://stackoverflow.com/questions/61107289/static-column-in-cassandra

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!