Sriranjan Manjunath
Sriranjan Manjunath

Reputation: 151

Limit on the number of columns in cassandra

Is there any limit on the number of columns in cassandra? I am thinking of using a unix timestamp (converted to TimeUUID) as the column key. In the worst case, I will end up having 86400 columns per row. Is this a good idea?

Upvotes: 8

Views: 9210

Answers (2)

vladaman
vladaman

Reputation: 3908

Having 86.400 columns per row is piece of cake for as long your columns are not too big and you don't retrieve all of them.

The maximum of column per row is 2 billion. See http://wiki.apache.org/cassandra/CassandraLimitations

A suggestion: For column name you should use Integer data serialization, which would take just 4 bytes for 1 second precision instead of using UUID (16 bytes); as long as your timestamps are all unique and 1s precision is enough.

Column names are sorted and you can use unix time as Integer. With this you can have fast lookups on columns.

There is also timestamp associated with each column, which can be useful to set in some cases. You cannot query on it, but may provide you additional information if needed.

Upvotes: 10

jbellis
jbellis

Reputation: 19377

Assuming you're doing that for a good reason, it's totally fine.

Upvotes: 7

Related Questions