I have read in the latest release that super columns are not desirable due to "performance issues", but no where is this explained.
Then I read articles such as this one that give wonderful indexing patterns using super columns.
This leave me with no idea of what is currently the best way to do indexing in Cassandra.
- What are the performance issues of super columns?
- Where can I find current best practices for indexing?
Super columns suffer from a number of problems, not least of which is that it is necessary for Cassandra to deserialze all of the sub-columns of a super column when querying (even if the result will only return a small subset). As a result, there is a practical limit to the number of sub-columns per super column that can be stored before performance suffers.
In theory, this could be fixed within Cassandra by properly indexing sub-columns, but consensus is that composite columns are a better solution, and they work without the added complexity.
The easiest way to make use of composite columns is to take advantage of the abstraction that CQL 3 provides. Consider the following schema:
Username here is the row key, but we've used a PRIMARY KEY definition which creates a grouping of row key and the sent_at column. This is important as it has the effect of indexing that attribute.
Behind the scenes Cassandra will store the above inserted data something like this:
But using CQL 3, we can query the "row" using a sent_at predicate, and get back a tabular result set.