Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started



376752150_179413 avatar image
376752150_179413 asked ·

What's behind the scene when update the primary key of Materialized view?

Say, the base table is:

create table t1(f1 int, f2 int, primary key (f1));

Since I want to support querying according f2 and also update f2:

select * from t1v1 where f2=2;
update t1 set f2=22 where f1=1;

I need the Materialized view:

create materialized view t1v1 as
select * from t1
where f2 is not null
primary key (f2, f1);

What's behind the scene when updating a base table's field, which is the primary key of Materialized view?

update t1 set f2=2222 where f1=1;

Does Cassandra do something as below?

1. select old f2 value from based table
2. mark the old row in the materialized view according the old f2 and f1 values.
3. insert the new row into materialized view.

By the way, is there any other way to support both updating field A and selecting by field A?

Best Regards,

materialized views
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

0 Answers