开发者

Columns count vs counter column performance

开发者 https://www.devze.com 2023-04-01 02:18 出处:网络
I am won开发者_开发知识库dering what is the best way to get the number of columns in a particular column family. I can get the number of columns directly but I am not sure if it is efficient solution.

I am won开发者_开发知识库dering what is the best way to get the number of columns in a particular column family. I can get the number of columns directly but I am not sure if it is efficient solution. On the other hand I can maintain another column family with a counter column that holds the number of columns. Do you have any experience with similar problems?


http://wiki.apache.org/cassandra/API explains that the get_count method:

...is not O(1). It takes all the columns from disk to calculate the answer. The only benefit of the method is that you do not need to pull all the columns over Thrift interface to count them.

If you only need the count very occasionally, and/or the number of columns is small, then this may not matter.

If performance matters, then you'd be better off with counters.

See http://www.datastax.com/dev/blog/whats-new-in-cassandra-0-8-part-2-counters

and How to increment a counter in Cassandra?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号