官术网_书友最值得收藏!

Materialized views

Data modeling principles in Cassandra compel us to denormalize data as much as possible. Prior to Cassandra 3.0, the only way to query on a non-primary key column was to create a secondary index and query on it. However, secondary indexes have a performance trade-off if they contain high cardinality data. Often, high cardinality secondary indexes have to scan data on all the nodes and aggregate them to return the query results. This defeats the purpose of having a distributed system.

To avoid secondary indexes and client-side denormalization, Cassandra introduced the feature of materialized views, which does server side denormalization. You can create views for a base table and Cassandra ensures eventual consistency between the base and view. This lets us do very fast lookups on each view following the normal Cassandra read path. Materialized views maintain a correspondence of one CQL row each in the base and the view, so we need to ensure that each CQL row that is required for the views will be reflected in the base table's primary keys. Although a materialized view allows for fast lookups on non-primary key indexes, this comes at a performance hit to writes. Also, using secondary indexes and materialized views increases the disk usage by a considerable margin. Thus, it is important to take this into consideration when sizing your cluster.

主站蜘蛛池模板: 灵丘县| 依兰县| 淮北市| 深泽县| 阳泉市| 西乡县| 双柏县| 乐至县| 赤壁市| 诏安县| 外汇| 安龙县| 广东省| 青龙| 从化市| 乌审旗| 丹巴县| 广饶县| 长乐市| 盘山县| 安远县| 东港市| 石台县| 祁阳县| 苍山县| 宜川县| 大城县| 连云港市| 辉南县| 南乐县| 社旗县| 巴马| 海安县| 阿鲁科尔沁旗| 碌曲县| 灌云县| 罗平县| 芜湖市| 焉耆| 营口市| 城步|