Database / Apache Cassandra Intermediate and Advanced interview questions
What is a materialized view in Cassandra?
A materialized view (MV) is a server-managed table that Cassandra automatically keeps in sync with a base table, letting you query the same data with a different partition/clustering key layout without hand-writing your own denormalization logic.
CREATE MATERIALIZED VIEW orders_by_status AS SELECT order_id, status, created_at FROM orders WHERE status IS NOT NULL AND order_id IS NOT NULL PRIMARY KEY (status, order_id);
- Every write to the base table is asynchronously propagated to update the corresponding row(s) in the view.
- The view has its own partition/clustering key structure, so it can support query patterns the base table's primary key can't.
- You cannot write directly to a materialized view — all writes must go through the base table.
Materialized views remove the need to manually write to two tables in your application code, but they add write amplification (every base write triggers a view update) and have had known consistency edge cases during node failures or repairs. Many teams still prefer manually managed denormalized tables for critical query paths, treating MVs as convenient but not fully mature for high-stakes production use.
More Related questions...