Difficulty: Intermediate
Estimated Time: 20 minutes

In this learning unit, you will:

  • Understand the purpose of materialized views
  • Explore several examples of using materialized views
  • Learn about limitations of materialized views

This scenario is also available on our datastax.com/dev site, where you can find many more resources to help you succeed with Apache Cassandra™.

Did you know?

You can use Cassandra as a service in the cloud. Nothing to install, no credit card required. Sign up and launch your database with a few clicks at astra.datastax.com!

In this scenario, you learned about:

  • Materialized views
  • Several examples of using materialized views
  • Limitations of materialized views

Materialized Views in Apache Cassandra™

Step 1 of 9

Materialized views

Each table only supports a limited set of queries based on its primary key definition. To support additional queries, the most generic and efficient solution is to duplicate the same data into a new table with a different primary key. This process is frequently referred to as data denormalization and data duplication. The drawback is that now you have to do multiple inserts, updates and deletes to maintain the same data stored in multiple places. You may even need to use atomic batches in some cases.

To remove the burden of keeping multiple tables in sync from a developer, Cassandra supports an experimental feature called materialized views. A materialized view is a read-only table that automatically duplicates, persists and maintains a subset of data from a base table. Any change to data in a base table is automatically propagated to every view associated with this table.

Materialized views are great for convenience but you should also be aware of their limitations, which we discuss later in this presentation.