kha
kha

Reputation: 20033

Cassandra table with multiple counter columns

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,

Upvotes: 11

Views: 1851

Answers (1)

BeepBoop
BeepBoop

Reputation: 1312

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

Upvotes: 4

Related Questions