james
james

Reputation: 23

Cassandra counters for distinct rows

I was reading about the use of Cassandra's built in counters. But for my use case I have for instance event data of clicks and I need counters for total clicks by campaign and counts of unique users that clicked by campaign. The first is easy but the second I could create a secondary table that is key'ed on the user id and campaign id. But I do not have a way to create a counter on an insert that would need to first read to see if it exists and if so then implement the counter for that type.

I am still reading about Cassandra and hope someone can shed light on the best way to handle this with performance in mind.

Upvotes: 0

Views: 88

Answers (1)

Marko Švaljek
Marko Švaljek

Reputation: 2101

There is a really nice post on the problem you are facing i.e. section about the "Can I maintain a count myself?":

http://www.wentnet.com/blog/?p=24

Basically the idea would be that you insert the unique id's of users into a single row and then count them later. But then again this approach brings it's own maintenance problems.

Upvotes: 1

Related Questions