How do I enable materialized views in Cassandra?

Viewed 836
create materialized view if not exists s.emp
as
select id, count(name) as count from employee primary key (name);

Query 1 ERROR: Materialized views are disabled. Enable in cassandra.yaml to use.

2 Answers

You'll need to add the following line to cassandra.yaml to enable materialised views:

materialized_views_enabled: true

You will need to enable it on all nodes of the cluster then perform a rolling restart for the change to take effect.

Note that MVs are considered experimental which is why they are disabled by default. Be aware of the pros and cons of MVs before using it in production as I've discussed in this post -- https://community.datastax.com/articles/2774/.

For more information on the experimental status of materialised views, see the entries in NEWS.txt on Github. Cheers!

This worked!

open the cassandra.yaml file, in mac if you have installed cassandra using

brew install cassandra

go to path /usr/local/etc/cassandra will find the cassandra.yaml file. Search for materialized view in that file.

and in place of

enable_materialized_views: false

by default will be false, change it to true

enable_materialized_views: true

Related