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,
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With