News Feeds

No results for 'undefined'
Powered by Algolia
How to choose my Cassandra key for correct default sorting?

Author: sdgfsdh

Originally Sourced from:

My table samples consists of columns like this:

id : uuid
created : timestamp
device : ascii
reading : float

Most of my queries will be to fetch the most recent n samples across all devices, so I would like this to be the default sorting:

SELECT * FROM samples LIMIT 1024

I would also like to be able to efficiently fetch the most recent n samples for a given device:

SELECT * FROM samples WHERE device = 'abc' LIMIT 1024

How should I design my partition key to achieve this?