Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Columns count vs counter column performance

Tags:

cassandra

I am wondering 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?

like image 337
Jacek L. Avatar asked Jul 21 '26 04:07

Jacek L.


1 Answers

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?

like image 159
DNA Avatar answered Jul 23 '26 19:07

DNA