Search code examples
cassandrahectorcql

Cassandra Query Language: get maximal key


I need to get a maximal key of a column family an cassandra database for further use. How can I get it using cassandra query language or hector API?


Solution

  • Unless you are using an ordered partitioner, which is usually a bad idea, getting the maximal key in a column family is very expensive. See this article for more details about random versus ordered partitioner.

    Generally you want to structure your cassandra data model so that you do gets on a single key, rather than gets on a range of keys. Often you have to denormalize your data to do so.