首页 文章

Apache Cassandra 3.0.0物化视图:由于对基础表的更改,视图的分区键是否会发生变化?

提问于
浏览
2

考虑到这一点,请纠正我的理解,如果这是不正确的 .

环境:Apache Cassandra v3.0.0

假设您有一个表并在其上创建了物化视图:

create table source(
id text, field text, stamp timestamp, data text, 
primary key(id, field))

create materialized view myview as
select * from source
where data is not null and id is not null and field is not null
primary key (data, field, id)

我的理解是 myview.data 本质上是视图的分区键( source 中的数据由服务器自动复制到 myview ?) .

If that is true, what happens internally when a table update is performed on source table and the source.data column is updated?

1 回答

  • 3

    我把它发布到Cassandra的用户邮件列表中,得到了以下两个有用的回复来回答这个问题 .

    它应该只是按预期工作,就好像通过魔法一样 . 这就是拥有MV的重点,因此Cassandra会为您完成所有的簿记 . 是的,分区键可以更改,因此对基表的更新可以导致删除一个(或多个)MV行,并创建一个(或多个)新的MV行 . 它本身不会更改分区键,但就好像它已被更改并且行被移动一样 . This can in fact result in the row moving from one node to another if the column(s) used in the MV partition key change in the base table row.

    • 杰克克鲁安斯基

    在更新数据源表的情况下,将为旧值生成逻辑删除,并为新值生成插入 . 这对于源分区是串行发生的,因此如果对同一分区有多个更新,则将为每个中间值生成一个逻辑删除 .

    此博客文章有更多详细信息:http://www.datastax.com/dev/blog/new-in-cassandra-3-0-materialized-views

    -Carl Yeksigian

相关问题