Cassandra

Think of the Cassandra column family as a map of map:

an outer map keyed by a row key, and an inner map keyed by a column key. Both maps are sorted.

  • A map gives efficient key lookup, and the sorted nature gives efficient scans. In Cassandra, we can use row keys and column keys to do efficient lookups and range scans.
  • The number of column keys is unbounded. In other words, you can have wide rows.
  • A key can itself hold a value. In other words, you can have a valueless column.

Range scan on row keys is possible only when data is partitioned in a cluster using Order Perserving Partitioner(OOP). OOP is almost never used.

So you can think of the outer map as unsorted:

Map<RowKey, SortedMap<ColumnKey,ColumnValue>>

 

Think about query patterns up front, and design column family accordingly, because of its high-scale distributed nature.

It's important to understand and start with Entities and Relationships, then continue modeling around query patterns by de-normalizing and duplicating.

Some queries might be executed only a few thousand times, while others a billion times.

Also consider which queries are sensitive to latency and which are not.

 

Don't de-normalize if you don't need to. It's all about finding the right balance.

 

Even if you can batch your reads, they will still be slower because Cassandra (Coordinator node, to be specific) has to query each row separately underneath(usually from different nodes).

Batch read will help only by avoiding the round trip - which is good, so you should always try to leverage it.

 

Remember that there are many ways to model. The best way depends on your use case and query patterns.

 

 

 

转载于:https://www.cnblogs.com/grep/p/3501260.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值