Search code examples
sqlcassandrapartitioningcqlcql3

Using CQL to walk partition keys of a Cassandra table


Using CQL3, how does one enumerate all the partition keys of a table in Cassandra? In particular there are complications with returning distinct keys, and paginating the results.


Solution

  • With a little pre-knowledge about the possible values of your keys, I think this could be done using with the help of the token function. Take a look at this answer. Is that what you are looking for?

    Also, native pagination seems to be an upcoming feature for 2.0. It's in the latest beta.

    Until 2.0 arrives, you can see this work-around for pagination on the datastax blog (go the "CQL3 pagination" section). This is, in principle, much the same as the link I posted above but goes into great detail how to implement pagination taking column keys into account etc.