incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher Wirt" <chris.w...@struq.com>
Subject Counters question - is there a better way to count
Date Thu, 05 Dec 2013 15:44:12 GMT
I want to build a really simple column family which counts the occurrence of
a single event X. 

 

Once we reach Y occurrences of X the counter resets to 0

 

The obvious way to do this is with a counter CF. 

 

CREATE TABLE xcounter1 (

                id uuid,

                someid int,

                count counter

) PRIMARY KEY (uid, someid)

 

This is how I've always done it in the past, but I've been told to avoid
counters for various reasons, performance, consistency etc..

I'm not too bothered about 100% absolute consistency, however read
performance is certainly a big concern.

 

So I was thinking to avoid using counters I could do something like this.

 

CREATE TABLE xcounter2 (

                id uuid,

                someid int,

                time timeuuid

) PRIMARY KEY (uid, someid, time)

 

Then retrieve all events and count in memory. Delete all id, someid records
once I hit Y.

 

Or I could 

CREATE TABLE xcounter3 (

                id uuid,

                someid int,

                time timeuuid, 

                Ycount int

) PRIMARY KEY (uid, someid, time)

 

Insert a 'Ycount' on each occurrence of the event. 

Only retrieve the last Y value inserted on reading

Then delete all records once I hit the magic Y value.

 

 

Anyone have any interesting thoughts or insight on what is likely to give me
the best read performance?

There will be 100's of someid to each id. Reads will be 5-10x the writes.

 

 

Thanks,

 

Chris


Mime
View raw message