Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassandra table with multiple counter columns

Tags:

cassandra

I was wondering if it was a good idea (performance wise) to have multiple counters on the same table/columnfamily in Cassandra? My current setup is this:

CREATE TABLE IF NOT EXISTS contentCounters (
downvotes counter,
comments counter,
upvotes counter,
contentid uuid,
PRIMARY KEY (contentid)
);

But I'm not sure whether or not it's ok, in terms of performance, to have multiple counters on the same table. Previously, I had 3 tables with counters (tracking upvote, downvote and comment counts) but I would like to combine them all to the above hierarchy to allow for fast queries to this table to get these values (as that is my use-case).

Any advise would be greatly appreciated.

Many thanks,

like image 432
kha Avatar asked Aug 05 '14 19:08

kha


1 Answers

I don't think this should be an issue. Cassandra doesn't update "rows" in their entirety. The "row" itself isn't locked during updates, but based on this article for 2.1+, just the counter column in the UPDATE statement identified by the specified partition key.

There is a better counter implementation in 2.1+ than in previous versions. Read more here

like image 148
BeepBoop Avatar answered Oct 27 '22 05:10

BeepBoop