Materialized Views with Cassandra

May 31st, 2016

In this screencast, Principal Engineer and Cassandra committer Gary Dusbabek provides an overview of Materialized Views, a feature added in Cassandra 3.0. Materialized Views allow you to automatically replicate primary data into other tables. Without this feature, you have to make all the updates yourself, including managing failures and retries.

All the code used in this video can be found here. The following are some highlights:

  • At 1:00, Gary provides an overview of the scripts and data used in the screencast. He uses song data as a simple example to illustrate the possibilities with Materialized Views.
  • At 3:19, Gary dives into the Docker image for this project. He walks through running the container, and how to use the Cassandra CQL shell to set up a schema and load the data.
  • At 4:50, Gary begins demonstrating the power of Materialized Views by writing a variety of queries, and creating alternate views to allow searches along parameters that don’t fall into the original primary key.
  • At 8:37, Gary explains some helpful things to remember, such as how the background updating process works, and how this affects performance.
  • At 10:39, Gary discusses a caveat — specifically: why you shouldn’t use Materialized Views when you have low cardinality. He also suggests that Materialized Views work particularly well with insert-only data.

The music in the video is “Modulation of the Spirit,” by Little Glass Men. It’s available under a CC by 3.0 US Creative Commons License.